[thelist] single select image from each gallery - MySQL
Bob Meetin
bobm at dottedi.biz
Wed Jul 2 18:57:35 CDT 2008
Group by seems to work fine, so quickly we forget...
select gallery_id, image_id from gallery, images where
gallery.gallery_id = images.image_gallery_id group by gallery_id
Bob Meetin wrote:
> 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.
>
More information about the thelist
mailing list