How acheive random results from a recordset that has INNER JOIN and GROUP BY in its SELECT statement?
I have three tables:
1) Categories (catID, catNAME)
2) Link Table (linkID, catID, galleryID)
3) Gallery (galleryID, domainID, galleryIMG)
I want to display a grouped list of categories on a page only where those categories exist because an image in the gallery table is linked to that category, via the link table.
The SELECT statement I've used is:
SELECT categories.catID, categories.catTITLE, link.galleryID, gallery.domainID, gallery.galleryIMG
INNER JOIN link ON categories.catID = link.catID
INNER JOIN gallery ON link.galleryID = gallery.galleryID
WHERE gallery.domainID = 1 GROUP BY categories.catTITLE
This is working perfectly and I can display an image from the gallery table alongside the grouped category title.
Is it possible to make the selection of gallery.galleryIMG random though? I've tried adding RAND() but, of course, it randomises the category title, not the image.
Hope that makes sense! Thank you.