php – mysql查询新读者的可用书籍
发布时间:2020-12-13 16:52:26 所属栏目:PHP教程 来源:网络整理
导读:我正在做一个图书馆管理系统项目. 我是 mysql查询的工作人员. 我有书桌(书),其中的字段是book_id | book_name | isbn_no | publisher_info 我在这个reader_id中有另一个读者表(读者) book_id | reader_name | reader_info |和book_return_status 现在我想要
我正在做一个图书馆管理系统项目.
我是 mysql查询的工作人员. 我有书桌(书),其中的字段是book_id | book_name | isbn_no | publisher_info 我在这个reader_id中有另一个读者表(读者) book_id | reader_name | reader_info |和book_return_status 现在我想要不在读者表中的图书清单的结果,因此列表将成为可用的图书清单. select * from books,reader where books.book_id != reader.book_id and reader.book_return_status = 1 但是没有给我正确的结果,我也尝试了这一个查询.. select * from books where book_id not in (select * from reader where book_return_status = 1) 但我没有给出结果. 我想预订不在读者表中的列表. 解决方法
您接近第二个查询.但是,为了不工作,您的子查询必须只返回ID:
select * from books where book_id not in (select book_id from reader where book_return_status = 1) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |