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

Home -> Community -> Usenet -> c.d.o.tools -> SQL syntax help

SQL syntax help

From: JohnN <jniels_at_att.net>
Date: 30 Jan 2002 10:27:50 -0800
Message-ID: <61e64477.0201301027.5b28e6f5@posting.google.com>

I need to construct a query (Oracle 8i)

Each parent record may have many child records.

I want to find parents for which the children do _not_ have a particular conditional.

One complication is that I can't simply filter on "not <condition>" since almost every parent I want to find will probably have some of the conditional children.

Simple Example

RecNo Condition
(parent) (in child)

  1       A
  2       B
  3       A
  3       B

If I just ask for records that don't contain "A", the return will include records 2 and 3. But one of the children of record three has the condition I am filtering for.

***NOW THE QUESTION***
I assume the following approach will work:

Link Parent and Child tables

  1. Fetch all Parent records [there are other filters]
  2. Fetch all Parent records with children that DO contain the condition I want to filter (this is a subset of the first)
  3. Display the non-intersection of the two parent record sets -- so that only records that DO NOT contain the condition I want to filter remain.

What SQL syntax will accomplish this? It's not a traditional self-join
<??>

TIA,
John Received on Wed Jan 30 2002 - 12:27:50 CST

Original text of this message

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