2012-10-17 362 views
2

我遇到了我的數據庫的問題。Microsoft Access - 輸入參數值爲什麼?

並試圖做多少交易有電影「Harry_Potter」的查詢?

所以我用SQL查詢:

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

但它要求Harry_Potter輸入參數值,爲什麼? 相關的SQL語句是

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); 

謝謝你的幫忙!如果我的數據庫設計有任何問題,請告訴我!謝謝!

回答

3

查詢更改爲類似

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

看到,因爲電影是一個字符串,你需要在你身邊正在尋找的價值的報價。

如果我沒有記錯的MS Access以「和SQL Server需要」

1

試試這個

md.movie = "Harry_Potter" 

我猜,你只是缺少你是比較字符串周圍的引號。

相關問題