How to join with three tables with multiple conditions? -


i want join 3 tables multiple conditions. below table structure , expected result

users_id    users_first_name       1           rocky    2           james    3           john          meeting_details_id   meeting_title   users_id  meeting_lead  close_meeting (no)      1               newmeet          3           1                  no      2               testmeet         2           2                  no    attended_meetings project_meeting_attendeeid  meeting_details_id  users_id   access_type (attendee)    1                             1                 2         attendee   

expected output:

query should check if meeting attended or users meeting lead

 meeting_title   creator   meeting_lead     close_meeting (no)   newmeet          john      rocky                  no   testmeet         james     james                  no 

try this:

select m.meeting_title,u1.users_first_name creator,u2.users_first_name meeting_lead,m.close_meeting meetingtable m left outer join users u1 on m.creator=u1.users_id left outer join users u2 on m.meeting_lead=u2.users_id 

result:

meeting_title   creator     meeting_lead    close_meeting newmeet         john        rocky           no testmeet        james       james           no 

see result in sql fiddle.


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -