Reputation: 3
I want to find all order_id and product_id from order_details table, where status_order from orders table does not contain "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")
Upvotes: 0
Views: 33
Reputation: 2454
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')
Upvotes: 1