mysql - sql join with where clause -
i using mysql have 2 tables join , tables larger know better way query them. tables used website storing pictures various users. kind of facebook. first table images table has id , source location field. , other table called user_images foreign key image id going image table. reason tables not put because multiple users can have same picture , doing things way away redundancy.
here query source locations of images particular user
select i.source_location user_images u inner join images on i.image_id = u.image_id u.user_id = 'user'
so question is, better query faster results shown below or not matter.
select i.source_location (select image_id user_images user_id = 'user') u inner join images on i.image_id = u.image_id
basically think doing clause before join make faster results because db have shorter set compare because join table alot smaller. dont know if right way of going through this. what best way go this? if else has better ways of doing please me out because see these tables getting rather large.
does images
table have user_id field?
if so, inner join images
on (i.image_id = u.image_id , i.user_id = "user")
Comments
Post a Comment