select oi.orderid as 'order id' from orderitems as oi where exists(Select 1 from inventory as inv where oi.partid = inv.partid and inv.description like '%gizmo%') and exists(Select 1 from inventory as inv where oi.partid = inv.partid and inv.description like '%gadget%') and not exists ( Select 1 from inventory as inv where oi.partid = inv.partid and inv.description not like '%gizmo%' and inv.description not like '%gadget%')
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)