Jump to content

Only recieving one result... REAL NEW, BE GENTLE


masteroleary

Recommended Posts

 

SELECT site.name AS name
FROM site
LEFT JOIN shoot_site ON site.id = shoot_site.site_id
LEFT JOIN model_shoot ON shoot_site.shoot_id = model_shoot.shoot_id
WHERE model_shoot.model_id = 6

 

Im only recieving one 'name' value when I should be getting two. My tables are like this:

table.Column1 => table.Column2

model_shoot.model_id = 6 => model_shoot.shoot_id = 1;2

 

shoot_site.shoot_id = 1 => shoot_site.site_id = 1

shoot_site.shoot_id = 2 => shoot_site.site_id = 2

 

site.id = 1 => site.name = 'Site 1'

site.id = 2 => site.name = 'Site 2'

Link to comment
Share on other sites

By 1;2 do you mean that there are two rows, one with value 1 and one with value 2?

 

A good approach to debugging this would be to remove one of the joins and see what happens.  Then try removing the other join as well.  Another option is to turn the left join into an inner join (which is probably what you want anyway), and also try an outer join to see what changes.

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.