On Tuesday, July 3, 2012 2:01:33 PM UTC+1, Ian Kirkham wrote:
> Hi Tim,
> What you are describing sounds like a bug & I'd suggest logging a call
> for this.
> Your workaround, given the dataset described, should give the same
> results but would be better written with LEFT join instead of FULL join
> as the latter has overheads that you don't need and would cause wrong
> results if there did happened to be rows in C that were not present in
> either A or B.
> Regards,
> Ian
> -----Original Message-----
> From: info-ingres-boun...@kettleriverconsulting.com
> [mailto:info-ingres-boun...@kettleriverconsulting.com] On Behalf Of Tim
> Ellis
> Sent: 03 July 2012 13:24
> To: info-ing...@kettleriverconsulting.com
> Subject: [Info-Ingres] Am I Missing something?
> 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?
> _______________________________________________
> Info-Ingres mailing list
> Info-Ing...@kettleriverconsulting.com
> http://ext-cando.kettleriverconsulting.com/mailman/listinfo/info-ingres