简体   繁体   中英

Microsoft Access - Enter Parameter Value why?

I am encountering a problem for my database.

And tried to do the query for how many transactions have movie "Harry_Potter"?

so I used SQL query:

SELECT
COUNT(td.movie) AS number_of_occurrence,
td.transaction_number
FROM
TransactionDetails td,
MovieDetails md
WHERE
md.movie = Harry_Potter

But it asks for Harry_Potter enter parameter value why? The relevant SQL statements are

CREATE TABLE TransactionDetails 
(
transaction_number INTEGER PRIMARY KEY,
movie VARCHAR(30) NOT NULL,
date_of_transaction DATE NOT NULL,
member_number INTEGER NOT NULL
)

CREATE TABLE MovieDetails
(
movie VARCHAR(30) PRIMARY KEY,
movie_type VARCHAR(3) NOT NULL,
movie_genre VARCHAR(10) NOT NULL
)

ALTER TABLE TransactionDetails
ADD CONSTRAINT member_number_fk FOREIGN KEY (member_number) REFERENCES    LimelightMemberDetails(member_number);

ALTER TABLE TransactionDetails
ADD CONSTRAINT transaction_number_drink_fk FOREIGN KEY (transaction_number) REFERENCES DrinkTransactionDetails(transaction_number);

ALTER TABLE TransactionDetails
ADD CONSTRAINT transaction_number_food_fk FOREIGN KEY (transaction_number) REFERENCES FoodTransactionDetails(transaction_number);

ALTER TABLE TransactionDetails
ADD CONSTRAINT movie_fk FOREIGN KEY (movie) REFERENCES MovieDetails (movie);

Thank you for your help! If there is anything wrong with my database design please let me know! thank you!

Change the query to something like

SELECT 
COUNT(td.movie) AS number_of_occurrence, 
td.transaction_number 
FROM 
TransactionDetails td, 
MovieDetails md 
WHERE 
md.movie = "Harry_Potter"

Seeing as movie is a string, you need quotes around the value you are looking for.

If I am not mistaken MS Access takes " and SQL SERVER takes '

try this

md.movie = "Harry_Potter"

I guess, you are simply missing the quotation marks around the string you are comparing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM