我寫了下面的查詢:顯示項目沒有價值
select title, branch_name, no_of_copies
from Book_Copies BC
inner join Book B on BC.book_id = B.book_id
inner join Library_Branch LB on BC.branch_id = LB.branch_id
where title = 'Grapes of Wrath';
但我的問題是,這種只顯示標題和具有> 0 no_of_copies分支名稱。如何顯示沒有no_of_copies行的行? (它將等於0)。
下面是表我目前得到:
+-----------------+-------------+--------------+
| title | branch_name | no_of_copies |
+-----------------+-------------+--------------+
| Grapes of Wrath | Central | 5 |
| Grapes of Wrath | Allentown | 2 |
+-----------------+-------------+--------------+
這就是我需要的是:
+-----------------+-------------+--------------+
| title | branch_name | no_of_copies |
+-----------------+-------------+--------------+
| Grapes of Wrath | Central | 5 |
| Grapes of Wrath | Allentown | 2 |
| Grapes of Wrath | Sharpstown | 0 |
+-----------------+-------------+--------------+
沒有看到表,我們無法修復您的查詢,但你需要使用一個左連接,而不是加盟都從左邊的表從右邊的項目和結果只有匹配 –