November 25, 2013 at 12:52 pm
Hi all,
I have a JOIN query that selects data from 3 specific tables, using a common field called "ReservationID". The column I am pulling from one of the tables is called "PropertyCode" and it contains only one of these 2 values: "ZIL" and "PCH".
I need to add an IF Statement in my query that will extract the data from the 3 tables only where the PropertyCode="ZIL". Can anyone help in formulating the correct syntax?
November 25, 2013 at 1:02 pm
hoolash (11/25/2013)
Hi all,I have a JOIN query that selects data from 3 specific tables, using a common field called "ReservationID". The column I am pulling from one of the tables is called "PropertyCode" and it contains only one of these 2 values: "ZIL" and "PCH".
I need to add an IF Statement in my query that will extract the data from the 3 tables only where the PropertyCode="ZIL". Can anyone help in formulating the correct syntax?
In your case, your "IF" is actually just a filter (WHERE) somedata matches a specific value.
to filter data, you just use a WHERE statement, something like this
SELECT
T1.ReservationID,
T1.PropertyCode,
T1.*,
T2.*,
T3.*
FROM Table1 T1
INNER JOIN Table2 T2
ON T1.ReservationID = T2.ReservationID
INNER JOIN Table3 T3
ON T1.ReservationID = T3.ReservationID
WHERE T1.PropertyCode='ZIL'
Lowell
November 25, 2013 at 2:10 pm
Thanks, Lowell! 🙂
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply