我想从order_details表中找到所有order_id和product_id,其中来自orders表的status_order不包含" O"," E"," P" ...
SELECT `order_id`, `product_id`
FROM `order_details`
WHERE `order_id`
NOT IN (SELECT `order_id` FROM `orders`
WHERE
`status`="O" OR
`status`="E" OR
`status`="P" OR
`status`="F" OR
`status`="I" OR
`status`="Y" OR
`status`="B" OR
`status`="J" OR
`status`="H" OR
`status`="G" OR
`status`="D")
答案 0 :(得分:1)
select od.order_id ,od.product_id
from order_details od
inner join orders os
on od.order_id = os.order_id
where os.status_order not in ('o','e','p')