In my query, I want to join tables only if the first table's specified column is null. How I can do the join. This is an INNER JOIN and there are 3 tables.
Here is my query.
SELECT item_id,item_name
FROM item i
INNTER JOIN supplier s ON i.item_id=s.items_id
INNER JOIN order O ON O.id=s.req_id
WHERE price>400 AND category='ALL';
this join should be available only if the column 'item_order_id' in the item table is NULL. If that column is not null, this join shuold not be done. How can I do in in Postgres (I use postgres 8).
AND i.item_order_id IS NULLto the where clause ?