users
[Top] [All Lists]

SQL syntax question

To: users@xxxxxxxxxx
Subject: SQL syntax question
From: "Jason Kretzer/STAR BASE Consulting Inc." <JKretzer@xxxxxxxxxxxxxxx>
Date: Wed, 7 Apr 2004 11:30:59 -0400
Delivered-to: mailing list users@cinjug.org
Mailing-list: contact users-help@cinjug.org; run by ezmlm

Slightly off topic but at least this query is being used in a java app.

I have three tables,  A   B  and AB.
I have two values which are PK in A B respectively,  Aid, Bid
I have a value from another table Cid
Cid is also in A
Aid Bid and Cid are in AB and are the PK together
Bid is a specified value referred to below as SP.Bid
Cid is a specified value referred to below as SP.Cid

I would like to get all records in A that meet the following criteria.  

records not present in AB whose AB.Cid=SP.Cid
combined with(UNION)
records present in AB whose AB.Aid=A.Aid and AB.Cid=SP.Cid and AB.Bid<>SP.Bid


I am having problems with the syntax, I can't seem to get it to come out right.

I know people have done these sort of joins before but I am more of a dabbler in SQL.  So, any help would be appreciated.

Thanks,

-Jason
<Prev in Thread] Current Thread [Next in Thread>