三种方法

确定哪些订单购买了 prod_id 为 BR01 的产品(二)

http://www.nowcoder.com/practice/999aa31a9a504c60baa088d90d82e64d

#方法一
select cust_id, order_date
from Orders,
(select order_num
from OrderItems
where prod_id="BR01") t
where t.order_num = Orders.order_num
order by order_date;
#方法二
select cust_id,order_date
from Orders 
where order_num in 
(select order_num
from OrderItems
where prod_id="BR01")
order by order_date;
#方法三
select cust_id,order_date
from Orders o join OrderItems oi on o.order_num=oi.order_num
where prod_id="BR01"
order by order_date;
全部评论
#方法四 select cust_id,order_date from Orders a,OrderItems b where a.order_num =b.order_num and b.prod_id ='BR01' order by order_date
2 回复 分享
发布于 2022-04-15 15:06
请问为什么方法三中,cust_id,order_date,以及prod_id前面不用加上所属表的名称?比如oi.prod_id,o.cust_id,o.order_date~
点赞 回复 分享
发布于 2023-02-07 16:23 辽宁

相关推荐

粗心的雪碧不放弃:纯学历问题,我这几个月也是一直优化自己的简历,后来发现优化到我自己都觉得牛逼的时候,发现面试数量也没有提升,真就纯学历问题
点赞 评论 收藏
分享
65 5 评论
分享
牛客网
牛客企业服务