题解 | #返回购买 prod_id 为 BR01 的产品的所有顾客的电子邮件(一)#

返回购买 prod_id 为 BR01 的产品的所有顾客的电子邮件(一)

http://www.nowcoder.com/practice/962b16554fbf4b99a87f4d68020c5bfb

三层子查询,先从最里层写,查询到prod_id ="BR01"的订单编号

select order_num from OrderItems where prod_id ="BR01"

查询到prod_id ="BR01"的客户id

select cust_id from Orders where order_num in (select order_num from OrderItems where prod_id ="BR01")

查询到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"))

当嵌套过多时容易被绕进去

全部评论

相关推荐

死在JAVA的王小美:哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈,我也是,让我免了一轮,但是硬气拒绝了
点赞 评论 收藏
分享
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务