题解 | #返回购买 prod_id 为 BR01 (二)#
返回购买 prod_id 为 BR01 的产品的所有顾客的电子邮件(二)
https://www.nowcoder.com/practice/c7aa73afc41f4dfc925baebdd175c345
# select # cust_email # from # Customers # inner join Orders on Customers.cust_id = Orders.cust_id # inner join OrderItems on OrderItems.order_num = Orders.order_num # where prod_id = 'BR01' select cust_email from Customers where cust_id in( select cust_id from Orders where order_num in( select order_num from OrderItems where prod_id = 'BR01' ) )
多层子查询
从上往下写,发现和别的表关联的字段就使用(select x from 表 where 另外一个字段xx in ())