tags:

views:

47

answers:

1

I have two product tables Product1 and Product2. There is a one 2 one mapping on the field ProductId.

What I want is to get all the product ids where the Product2.Exported field is false AND Where the product ids that are in Product1 but not in Product2 table.

Right now I have two queries that I'm trying to mash into one.

SELECT ProductId FROM Product1 WHERE ProductId NOT IN(Select ProductId From Product2)
SELECT ProductId FROM Product2 WHERE Exported = 0
+6  A: 

Use a union (or union all to include duplicates):

SELECT ProductId FROM Product1 WHERE ProductId NOT IN(Select ProductId From Product2) 
union 
SELECT ProductId FROM Product2 WHERE Exported = 0 
Ray