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'

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.