Java数据库编程技术 第二章习题

1.没有被读者借阅的图书信息

SELECT `bName`,`bid`,`author`,`pubComp`,`price`
	FROM book WHERE bid NOT IN (
			SELECT nif FROM borrow
	)

2.今年所有缴纳罚款的读者清单

SELECT reader.rName,book.bName,pDate,amount FROM penalty
INNER JOIN reader ON penalty.rid=reader.rid
INNER JOIN book ON penalty.bid=book.bid
WHERE YEAR(pDate)=YEAR(NOW())

3.地址为空的所有读者尚未归还的图书清单

SELECT reader.rid,reader.rName,book.bName,lendDate,willDate,returnDate FROM borrow
INNER JOIN reader ON  borrow.rid=reader.rid
INNER JOIN book ON   borrow.nif=book.bid 
WHERE borrow.rid IN(
SELECT reader.rid FROM reader WHERE rAddress IS NULL
) AND returnDate IS NULL ORDER BY borrow.rid DESC,lendDate ASC

 

你可能感兴趣的:(Java数据库编程技术 第二章习题)