I have three tables, Table_A, Table_B and Table_C
All rows on Table_A have a corresponding row on Table_B and vice versa
All row on Table_C have a corresponding row on Table_A (and table_B)
Not all rows on Table_A (and Table_B) have corresponding rows on Table_C
Table_A includes a TYPE field - their are two types - "W" and "X"
Table_B includes a COUNT field that holds a numeric value from 0 up
All tables are BTREE Unique on the ID field
I want to select values where either
1) TYPE = W and COUNT > 5
2) TYPE = X and COUNT > 0
3) A record exists on Table_C
SELECT * FROM TABLE_A,TABLE_B
WHERE
A.ID =
B.ID AND
( (A.TYPE = "W" AND B.COUNT > 5) OR
(A.TYPE = "X" AND B.COUNT > 0) OR
EXISTS (SELECT 1 FROM TABLE_C WHERE
C.ID =
B.ID)
)
fails with E_US1196 SELECT returned multiple values
The query executes if I omit either the EXISTS line, or the two A.TYPE= lines
I can rewrite the query to explicitly use asn outer join
SELECT * FROM TABLE_A, TABLE_B FULL JOIN TABLE_C on
B.ID =
C.ID
WHERE
A.ID =
B.ID AND
( (A.TYPE = "W" AND B.COUNT > 5) OR
(A.TYPE = "X" AND B.COUNT > 0) OR
C.ID IS NOT NULL
)
Which works. But shouldn't the two statements be functionally equivalent?