Isaac
Lifelong Learner
- Local time
- Today, 14:39
- Joined
- Mar 14, 2017
- Messages
- 8,777
I have a really dumb question that makes it appear I've never written a query before, but here goes. Just to make sure I haven't gotten amnesia or my head is screwed on wrong today.
If I have one table.....MAINTABLE, and one "exclusion" query, let's call it EXCLUSION. I want to select records from MAINTABLE but make sure they are NOT in EXCLUSION. (EXCLUSION exists for the purpose of listings things I want to make sure NOT to include).
Isn't this 100% effective? Any gotcha's or something I've forgotten?
I'm not worrying about Access sql syntax here - just putting this here for general ansi syntax, although I am doing this in Access......and dragging two ID fields for a left join, where maintable is on the left, and exclusion is on the right.
this is my standard way of excluding things pretty much always rather than using not exists or a subquery etc
If I have one table.....MAINTABLE, and one "exclusion" query, let's call it EXCLUSION. I want to select records from MAINTABLE but make sure they are NOT in EXCLUSION. (EXCLUSION exists for the purpose of listings things I want to make sure NOT to include).
Isn't this 100% effective? Any gotcha's or something I've forgotten?
I'm not worrying about Access sql syntax here - just putting this here for general ansi syntax, although I am doing this in Access......and dragging two ID fields for a left join, where maintable is on the left, and exclusion is on the right.
Code:
select MAINTABLE.* FROM MAINTABLE LEFT JOIN EXCLUSION on MAINTABLE.ID=EXCLUSION.ID where EXCLUSION.ID is null
this is my standard way of excluding things pretty much always rather than using not exists or a subquery etc