2014-03-19 124 views
0

我應該編寫一個SQL查詢語句,它將選擇當前已檢出並已過期的所有圖書,這些圖書的返回值大於圖書館系統中的$ 10.00。我應該返回借閱者的姓名,地址,郵政編碼和電話號碼,負責交易的圖書管理員的姓名和電話號碼,圖書應歸還的日期以及姓名,費用和ISBN號碼這本書。我的查詢應按降序排列返回日期的列表。sql select語句,正確選擇語句的指南

這是我寫的

Select a.returndate as booklended ,a.isbn_number as booklended, b. as borrower,   
        b.address as borrower, b.postalcode as borrower, b. phonenumber as 
        borrower, c.name as  librarian, c.phonenumber as librarian 
       from booklended.a, librarian.c, borrower.b 
    where a. librarian id= c.librarianid 
     and a.librarycard = b.librarycard 
     and returndate < curdate() 
     and cost > 10.00 
       order by a. returndate desc; 

但是我得到這個錯誤 5:無效的架構名稱:中陳述BOOKLENDED [如booklended,a.isbn_number作爲booklended選擇a.returndate,B。作爲借款人,b.address作爲借款人,b.postalcode作爲借款人,b。 PHONENUMBER作爲借款人,c.name圖書管理員,c.phonenumber圖書管理員

從booklended.a]

我能請得到我如何可以解決此指南。謝謝

+0

的錯誤說 「你有沒有指定的數據庫booklended」。 – fancyPants

+0

a,b和c是表格的別名。根據您的數據庫管理器,可以通過編寫'booklended a'(無期限)或'booklended as a'來創建別名。它看起來像你的問題源於在表名稱中使用句點。 'where'語句也有問題。 –

+0

另外,不要使用隱式(逗號 - )連接語法。改爲使用顯式JOIN語法。 – Strawberry

回答

0

嘗試此查詢

Select a.returndate as booklended ,a.isbn_number as isbnNumber, b.[YOUR COLUMNNAME FROM BORROWER TABLE] as borrower,  b.address as borrower, b.postalcode as borrower, b. phonenumber as borrower, c.name as  librarian, c.phonenumber as librarian 

    from booklended as a, librarian as c, borrower as b 
    where a.librarian id= c.librarianid 
     and a.librarycard = b.librarycard 
     and returndate < curdate() 
     and cost > 10.00 
       order by a. returndate desc; 
+0

感謝您的回覆,但我得到了以下錯誤。1:未找到列:B.AS在語句中[選擇a.returndate作爲booklended,a.isbn_number作爲isbnNumber,b。作爲借款人,b.address作爲借款人,b.postalcode作爲借款人,b。 phonenumber as borrower,c.name as librarian,c.phonenumber as librarian from booklended as a,librarian as c,borrower as b where a.librarian] – user2287434

+0

for that add these columns to your table.thatsall –

0

試試這個:

Select a.returndate as booklended ,a.isbn_number as booklended,  
b.address as borrower, b.postalcode as borrower, b.phonenumber as 
borrower, c.name as librarian, c.phonenumber as librarian 
from booklended a, librarian c, borrower b 
where a. librarian id= c.librarianid 
and a.librarycard = b.librarycard 
and returndate < curdate() 
and cost > 10.00 
order by a.returndate desc;