KnightDeveloper
08-31-2009, 04:27 PM
I'm having trouble figuring out what's wrong with my SQL query. If I execute the following, which returns a product id from one table that is also found in another products table, then it works properly.
SELECT prod_id from products1 WHERE products1.prod_id IN (SELECT prod_id FROM products2)
However what I really want to do is to return products that do not appear in the second table. I've tried the following but none of them work:
SELECT prod_id from products1 WHERE products1.prod_id NOT IN (SELECT prod_id FROM products2)
SELECT prod_id from products1 WHERE products1.prod_id <> ANY (SELECT prod_id FROM products2)
SELECT prod_id from products1 WHERE products1.prod_id <> ALL (SELECT prod_id FROM products2)
Can anyone help me figure what's wrong?
SELECT prod_id from products1 WHERE products1.prod_id IN (SELECT prod_id FROM products2)
However what I really want to do is to return products that do not appear in the second table. I've tried the following but none of them work:
SELECT prod_id from products1 WHERE products1.prod_id NOT IN (SELECT prod_id FROM products2)
SELECT prod_id from products1 WHERE products1.prod_id <> ANY (SELECT prod_id FROM products2)
SELECT prod_id from products1 WHERE products1.prod_id <> ALL (SELECT prod_id FROM products2)
Can anyone help me figure what's wrong?