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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Return rows where no matching ID exists 1

Status
Not open for further replies.

hapax

Programmer
Nov 10, 2006
105
US
I have the following query:

Select *
FROM Unit u
inner join Event ev on
ev.UnitId = u.UnitId

But what I really want is something that does the opposite - returns all the records where no ev.UnitId exists for a given u.UnitId. How do I do that?
 
Code:
Select *
FROM Unit u
LEFT join Event ev on
    ev.UnitId = u.UnitId
where ev.UnitID IS NULL
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top