Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select unique values 1

Status
Not open for further replies.

vladk

Programmer
May 1, 2001
991
US
Hi,

The table Table1 has two fields Field1 and Field2. I would like to select two sets of the values: the values that can be found in Field1 only and the values that can be found in Field2 only.

I am sure this must be very easy, but I am just stuck!

Thank you!

vladk
 
As in (?):

[tt]Select Field1 From Table1 Where Field1 <> Field2 Or Field2 Is Null[/tt]
 
Remou,

Thank you for the reply. Actually, I developed the right SELECT!

SELECT A.Field1
FROM Table1 A
WHERE NOT EXISTS (SELECT B.Field2
FROM Table1 B
WHERE B.Field2 = A.Field1)


vladk
 
Another way:
SELECT A.Field1
FROM Table1 A LEFT JOIN Table1 B ON A.Field1 = B.Field2
WHERE B.Field2 IS NULL

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PHV,

I always count on you!

Thank you!!

vladk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top