Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Query Help - Stumped...

Query Help - Stumped...

From: <thecake_at_my-deja.com>
Date: 2000/04/29
Message-ID: <8eekuc$hed$1@nnrp1.deja.com>#1/1

Please Help! I have a relational database question regarding how to get the information I need out of the database with 1 single line of SQL that answers the following question:

Using TABLE Z, find all TABLE A records that have ANY of these TABLE B records (b, g) OR ALL of these TABLE B records (a,c). The result should return:

1 (because it has BOTH A,C)
3 (because it has b)
4 (because it has b – also happens to have BOTH A,C)
5 (because it has g)
6 (because it has BOTH A,C)

PLEASE KEEP IN MIND that the two sets above (b, g) and (a, c) could actually contain many more items in the real world! Feel free to reply here or email at:

thecake_at_writeme.com - THANKS in Advance!

Here is a simple example of the data (THIS IS ONLY AN EXAMPLE. I used numbers and letters for in the hopes of being clear, the real data is obviously primary keys of INT).

TABLE A
COL A1
1
2
3
4
5
6

TABLE B
COL B1
a
b
c
d
e
g

TABLE Z

COL A1		COL B1
1		a
1		c
2		a
2		d
3		a
3		b
3		e
4		a
4		b
4		c
5		g
6		a
6		c



Sent via Deja.com http://www.deja.com/
Before you buy. Received on Sat Apr 29 2000 - 00:00:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US