[thelist] single select image from each gallery - MySQL

Bob Meetin bobm at dottedi.biz
Wed Jul 2 17:34:29 CDT 2008

I have images in galleries; each image has a unique id and each gallery 
has a unique id.

select gallery_id, image_id from gallery, images where 
gallery.gallery_id = images.image_gallery_id

This gives me a nice list of everything by gallery_id, image_id.  Say I 
want to get a single image from each gallery.  How can you do this in a 
single query? I remember back in sybase days you run the first query and 
place in a temp table, then run the second.

select distinct gallery_id from gallery 


More information about the thelist mailing list