1,105,644 Community Members

Left Join and inner join latter

Member Avatar
newbie14
Practically a Master Poster
687 posts since Jan 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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
Member Avatar
pritaeas
mod_pritaeas
11,318 posts since Jul 2006
Reputation Points: 1,420 [?]
Q&As Helped to Solve: 1,835 [?]
Skill Endorsements: 156 [?]
Moderator
Featured
Sponsor
 
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
Member Avatar
newbie14
Practically a Master Poster
687 posts since Jan 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 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.

Member Avatar
pritaeas
mod_pritaeas
11,318 posts since Jul 2006
Reputation Points: 1,420 [?]
Q&As Helped to Solve: 1,835 [?]
Skill Endorsements: 156 [?]
Moderator
Featured
Sponsor
 
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
Member Avatar
newbie14
Practically a Master Poster
687 posts since Jan 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 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.

Question Answered as of 2 Years Ago by pritaeas
Member Avatar
pritaeas
mod_pritaeas
11,318 posts since Jul 2006
Reputation Points: 1,420 [?]
Q&As Helped to Solve: 1,835 [?]
Skill Endorsements: 156 [?]
Moderator
Featured
Sponsor
 
0
 

Glad it works. It was hard to tell which of your queries were really needed.

Member Avatar
newbie14
Practically a Master Poster
687 posts since Jan 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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

You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: