练习:

答案:
我的写法
select
distinct c.customer_id,
c.first_name,
c.last_name
from customers c
join orders o using (customer_id)
where o.order_id in
(select oi.order_id
from order_items oi
where oi.product_id=3)
老师的写法
select
distinct customer_id,
first_name,
last_name
from customers c
join orders o using (customer_id)
join order_items oi using(order_id)
where oi.product_id=3

SQL联接查询示例:我的写法vs老师的优化
本文对比了两种SQL查询方式,一种是通过嵌套子查询获取特定产品订单的客户信息,另一种是直接使用JOIN操作。展示了老师建议的JOIN方法在效率上的优势。
111

被折叠的 条评论
为什么被折叠?



