# 查詢客戶id為1的任意訂單中產品總價超過30的產品名稱

瓜瓜東西發表於2014-04-09


SELECT p.prod_name ,p.prod_id FROM products p INNER JOIN orderitems oi
ON oi.prod_id = p.prod_id AND  oi.item_price >30 AND oi.order_num IN
(
  SELECT o.order_num FROM orders o LEFT JOIN customers ct ON ct.cust_id = o.cust_id AND ct.cust_name = 'xxx'

 

相關文章