题解 | #返回购买 的产品的所有顾客的电子邮件(二)#
返回购买 prod_id 为 BR01 的产品的所有顾客的电子邮件(二)
https://www.nowcoder.com/practice/c7aa73afc41f4dfc925baebdd175c345
首先查找prod_id为BR01的项
select order_num from OrderItems where prod_id = 'BR01'
其次提取Orders表数据
最后用select子查询将Customers表和Orders表进行联结,从中取出符合条件的cust_email数据
select (select cust_email from Customers cs where os.cust_id = cs.cust_id) from Orders os where order_num in ( select order_num from OrderItems where prod_id = 'BR01' )