0

Dear All,
I got one table as the tblMasterData then I left join it with another table like this tblEventAlert. So what I want to do if there is a match between tblMasterData and tblEventAlert then for that tblEventAlert I would like to match it with tblDevice to to get the device details?

FROM tblMasterData 
LEFT JOIN tblEventAlert ON tblMasterData .eventAlertID=tblEventAlert.eventAlertID 
LEFT JOIN   tblEventAlert.deviceID=tblDevice.deviceID And tblEvent.eventAlertID>0
2
Contributors
6
Replies
8
Views
5 Years
Discussion Span
Last Post by newbie14
0
SELECT *
FROM tblMasterData MD, tblEventAlert EA, tblDevice D, tblEvent E
WHERE MD.eventAlertID = EA.eventAlertID
AND EA.eventAlertID = D.eventAlertID
AND D.eventAlertID = E.eventAlertID
AND E.eventAlertID > 0
0

Dear Pritaeas,
The problem is the tblMasterData does not have all eventAlertID for each data so I have to do left inner join. IF not I will miss other data those without the alertID.

0
SELECT *
FROM tblMasterData MD
LEFT JOIN tblEventAlert EA ON MD.eventAlertID = EA.eventAlertID
LEFT JOIN tblDevice D ON EA.eventAlertID = D.eventAlertID
LEFT JOIN tblEvent E ON D.eventAlertID = E.eventAlertID AND E.eventAlertID > 0
0

Dear Prit,
I think this LEFT JOIN tblEvent E ON D.eventAlertID = E.eventAlertID AND E.eventAlertID > 0 not necessary could solve it ready. Thank you.

0

Dear Prit,
Is ok I do understand thank you very much for your inside into my problem.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.