Problem: SE 5.06, outer joins and nulls
Posted in 1997
Topics: SQL Development & Query Writing
I'm trying to do an outer join between two tables, say:
domtable(id, base_value)
subtable(id, current_value)
where a subtable record is created when the base_value in the domtable
is no longer valid as a current value.
my query runs like so:
select domtable.id, domtable.base_value
from domtable, outer subtable
where subtable.current_value is null
and domtable.id = subtable.id
One problem is that the above query returns all rows driven by
domtable regardless if the row's counterpart in subtable has a null
value in current_value or not.
Additionally, when I change the query slightly:
select domtable.id, subtable.current_value
from domtable, outer subtable
where subtable.current_value is not null
and domtable.id = subtable.id
both of these queries return the same set of domtable.id suggesting that
subtable.current_value is both null and not null for rows in the
result table where there was not a subtable record to correspond with the
domtable record driving the outer join.
From the Informix Guide to SQL, Tutorial, December 1991 on P 3-19 in the
section on Outer Joins, I see:
"In an outer join, the result contains the combination of rows from the
tables that satisfy the join conditions [domtable.id = subtable.id].
Rows from the dominant table that would otherwise be discarded are
preserved, even though no matching row was found in the subservient
table. The dominant table rows that do not have a matching subservient
table row receive a row of nulls before the selected columns are
projected."
To make matters worse, these "not quite nulls" match every relational
operation I apply to the field that is supposed to be null (real
nulls fail these)
Is this a known bug? I've seen some rumblings on here that indicate that
this might be, but I couldn't tell if the problem that was briefly
mentioned was the same as mine.
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet