Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Am I Missing something?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Tim Ellis  
View profile  
 More options Jul 3 2012, 8:23 am
Newsgroups: comp.databases.ingres
From: Tim Ellis <tell...@csc.com>
Date: Tue, 3 Jul 2012 05:23:37 -0700 (PDT)
Local: Tues, Jul 3 2012 8:23 am
Subject: 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?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ian Kirkham  
View profile  
 More options Jul 3 2012, 9:01 am
Newsgroups: comp.databases.ingres
From: "Ian Kirkham" <Ian.Kirk...@actian.com>
Date: Tue, 3 Jul 2012 09:01:33 -0400
Local: Tues, Jul 3 2012 9:01 am
Subject: Re: [Info-Ingres] Am I Missing something?
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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tim Ellis  
View profile  
 More options Jul 3 2012, 11:25 am
Newsgroups: comp.databases.ingres
From: Tim Ellis <tell...@csc.com>
Date: Tue, 3 Jul 2012 08:25:53 -0700 (PDT)
Local: Tues, Jul 3 2012 11:25 am
Subject: Re: [Info-Ingres] Am I Missing something?

Thanks Ian
I'll raise a call tomorrow

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »