嵌套查询
在sql语言中,一个select_from_where语句称为一个查询块。将一个查询块嵌套在另一个查询块的where子句或having短语的条件中的查询称为嵌套查询。
如查找购买了’数据库系统概论‘的客户信息,代码如下
select customer.*
from customer
where cust_name in(
select cust_name
from sales
where order_no in(
select order_no
from sale_item
where book_no in(
select book_no
from books
where book_name='数据库系统概论') ) );