RE: Help with SQL syntax
Posted in 1995
Topics: SQL Development & Query Writing
Well,
the SQL Reference Manual states:
>> An outer join between two tables treats the two tables asymmetrically.
One of the tables (sometimes calles a "preserved" tables) is dominant
and the other table is subservient. If the subservient table has no rows
satisfying the join condition, the outer join attaches a row of NULL values
to the row of the dominant table before projecting the desired columns. <<
In your case, this means that
>> WHERE account.acc_name = temp.acc_name
AND temp.acc_name IS NOT NULL <<
is the join condition, i.e. that if in temp exists a row where acc_name is null, you
should get the NULLs for the temp-columns (or in your select: you get the row
though the temp.acc_name is null).
One way to accomplish the task you want to do could be the use of a SUB-SELECT:
SELECT ... FROM account WHERE NOT EXISTS
(SELECT * FROM temp WHERE temp.acc_name IS NOT NULL
AND temp.acc_name = account.acc_name)
Bernhard Rawein
Alphatron GmbH
Munich, Germany