Jump to content

[SOLVED] Arg! Can I use LIKE with ; delimited ids while JOINING?


masteroleary

Recommended Posts

This is what I have so far. Im completely new to mysql. I need to get site.name with the data model_shoot.model_id

 

My tables include two columns:

model_shoot.model_id model_shoot.shoot_id

 

shoot_site.shoot_id shoot_site.site_id

 

site.id site.name

 

The second column ids are ; delimited (i.e. model_shoot.shoot_id = 1;4;5;7)

 

 

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

pretty much just like I said. They're just small tables with 2 or 3 columns that link one to many's or many to many's.

 

eg. model_shoots table

id   model_id   shoot_id
1    22               4
2    24               4

 

So if i have this i would say 'SELECT site.name

FROM site

JOIN shoot_site ON shoot_site.site_id = site.id 

JOIN model_shoot ON model_shoot.shoot_id = shoot_site.shoot_id

WHERE model_shoot.model_id = 1' ?? and i should get two rows with names for site 1 & 2?

Table model_shoot
id   model_id   shoot_id
1    1               4
2    1               5
3    2               1

Table shoot_site
id   shoot_id   site_id
1    4              1
2    4              2
3    5              2

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.