mysql - How to select photos that are in selected albums -


i couldn't figure out how word question, i'm going use typical example. imagine have common design photo albums 3 tables - photos, albums, photo_albums (a lookup table). albums names a, b , c.

how find photos in both , c?

if table design , want filter on album name. can this:

select     *     photos exists (     select         null             photo_albums         join albums             on photo_albums.albumid=albums.albumid             photos.photoid=photo_albums.photoid         , albums.albumname in ('a','b') ) 

i think better solution via id if have one. this:

select     *     photos exists (     select         null             photo_albums             photos.photoid=photo_albums.photoid         , photo_albums.albumid in (1,3) ) 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -