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!

Questions

Status
Not open for further replies.

mayu03

Programmer
Oct 3, 2003
91
US
In first query I am getting result back.Second query should get the same data back (just different syntax). I can't see where my error is, but my second query is not returning any result back.Pleae help
1.select a.lastname
from Table1 a Left join table2 b
On a.lastname=b.last
2. select a.lastname
from Table1 a
where NOT EXISTS (select last from table2 )
 
If you want data from Table1 that doesn't appear in Table2, then both queries need a little work.

Query 1:
select a.lastname
from Table1 a Left join table2 b
On a.lastname=b.last
where b.last is null

Query 2:
select a.lastname
from Table1 a
where NOT EXISTS (select last
from table2 b
where b.last = a.lastname)


--Angel [rainbow]
-----------------------------------
Every time I lose my mind, I wonder
if it's really worth finding.
 
Or, if your original query1 is giving you the results you want, change Query 2 to the following:

select a.lastname
from Table1 a
where a.lastname IN (select last from table2
where a.lastname = b.last)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top