Jump to content

Return result set even when a join is null


GregL83

Recommended Posts

Hello,

 

I am trying to return a mysql result with multiple table joins...  I need to return these results even if one of the table join returns null...  Is this possible???

 

here is my query:

SELECT sc.name AS name, sc.slug AS slug, ct.name AS city, st.name AS state, sp.picture_id FROM scenes sc JOIN cities ct ON sc.city_id = ct.city_id JOIN states st ON sc.state_id = st.state_id JOIN (SELECT scene_id, picture_id FROM scene_pictures ORDER BY picture_id DESC LIMIT 1) sp ON sc.id = sp.scene_id ORDER BY sc.id DESC LIMIT 5

 

the table scene_pictures sometimes DOES NOT have any pictures, but I would still like to return the rest of the fields...

 

Any help???

 

Thanks in advance

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.