Hi, in Informix dialect (and ANSI SQL I believe) the construction
Code:
WHERE tp_promo3.sl_store NOT IN
(SELECT * FROM tp_promo1, tp_promo3 WHERE tp_promo1.sl_store = tp_promo3.sl_store)
is not valid because the (NOT) IN operator works on simple operands only. So you should use
Code:
FROM tp_promo1
WHERE sl_store NOT IN (SELECT sl_store FROM tp_promo3)
instead. Another approach is to use a correlated subquery like
Code:
FROM tp_promo1
WHERE NOT EXISTS
(SELECT * FROM tp_promo3 WHERE tp_promo1.sl_store = tp_promo3.sl_store)
but the first solution probably performs better.
The 19000 rows you're mentioning are a result of the cartesian product of the join without a discrete join clause of
Code:
FROM tp_promo1, tp_promo3
WHERE tp_promo1.sl_store <> tp_promo3.sl_store
This way you'll get a resultset of approximately 139 * (145 -9) records.
Regards,
Hans