can I use WHERE clause with JOIN?

davidnewbie

Registered User.
Local time
Today, 10:26
Joined
Oct 6, 2008
Messages
13
Does anyone know if you can use the WHERE clause after a JOIN is done?
I have a join which gets what I need (basically getting the latest records out of a table "tblHistory"
----------------------
SELECT A.* FROM tblHistory AS A
INNER JOIN

(SELECT id, max([Entry Datime]) as maxEntryDatime FROM tblHistory WHERE HousingId='SJ RH1' GROUP BY id) AS B
ON (A.[Entry Datime] = B.maxEntryDatime) AND (A.id = B.id);
----------------------

Now, that I have the latest records I want to say WHERE anotherField='TRUE' to grab just specific records for my resultset...
 
Certainly... But haven't you tried it - just to see with your own eyes?

You'll probably want to include this new criteria of yours (which, if the datatype is boolean, will be WHERE anotherField = TRUE) in both the main body and subquery to ensure accurate matching on the inner condition?
 
ah, thank you.:)
I just had a syntax error... because it was giving me a weird error mesg, I was thinking it wasn't allowed..
 

Users who are viewing this thread

Back
Top Bottom