SQL加入和预订

时间:2018-04-10 18:35:05

标签: sql join where

我被要求加入两个单独的表格,找到1993年6月保留的所有书籍的书号和标题。预订数据库是

Book_reservation (kb_bor_no, kb_isbn, kb_reserve_date) VALUES  
('B0000006','09952500','20-NOV-1991');

Book_reservation (kb_bor_no, kb_isbn, kb_reserve_date) VALUES
('B0000004','45002286','13-JUN-1993');

Book_reservation (kb_bor_no, kb_isbn, kb_reserve_date) VALUES
('B0000004','86007906','13-JUN-1993');

Book_reservation (kb_bor_no, kb_isbn, kb_reserve_date) VALUES
('B0000009','55213462','30-JUN-1993');

Book_reservation (kb_bor_no, kb_isbn, kb_reserve_date) VALUES
('B0000007','45002286','01-JUL-1993');

Book_reservation (kb_bor_no, kb_isbn, kb_reserve_date) VALUES
('B0000002','72216393','02-JUL-1993');

Book_reservation (kb_bor_no, kb_isbn, kb_reserve_date) VALUES
('B0000008','45002286','03-JUL-1993');

Book_reservation (kb_bor_no, kb_isbn, kb_reserve_date) VALUES
('B0000007','45000918','11-JUL-1993');

到目前为止,我有这段代码:

SELECT DISTINCT 
    Book_Book.kb_title, Book_Reservation.kb_isbn
FROM  
    Book_Book 
JOIN 
    Book_Reservation ON (Book_Book.kb_isbn = Book_Reservation.kb_isbn);

但我不知道如何过滤它只显示1993年6月保留的书籍,我不知道在下面的WHERE条款中放什么

1 个答案:

答案 0 :(得分:0)

SELECT Book_Book.kb_title, Book_reservation.kb_isbn
FROM Book_Book JOIN Book_reservation
ON (Book_Book.kb_isbn = Book_reservation.kb_isbn)
WHERE kb_reserve_date>='01-JUN-1993' AND
kb_reserve_date < '01-JUL-1993'