三种写法:
#1.
#select cust_id from Orders left join OrderItems using(order_num)
#where item_price >= 10
#2.
# select cust_id from Orders, OrderItems
# where Orders.order_num = OrderItems.order_num
# and item_price >= 10
#3.
select cust_id from Orders
where order_num in(
select order_num from OrderItems where item_price >= 10
)
三种写法:
# select cust_id,order_date from Orders left join OrderItems using(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
select cust_id,order_date from Orders a
where order_num in (
select order_num from OrderItems
where prod_id = 'BR01'
)
order by order_date
三种写法:
# select cust_email from Customers left join Orders using(cust_id)
# left join OrderItems using(order_num)
# where prod_id = 'BR01'
# select cust_email from Customers a, Orders b,OrderItems c
# where a.cust_id =b.cust_id and b.order_num = c.order_num
# and 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'
)
)