Error in SQL syntax? Have never managed to solve this.
<?php
$rsGALLERYSUBCS = new WA_MySQLi_RS("rsGALLERYSUBCS",$csdbmysqli,20);
$rsGALLERYSUBCS->setQuery("SELECT NJlinkcatsubgal.NJcatSUBID, NJcategoriesSUB.NJcatSUBTITLE, galleryRand.NJgalleryID, galleryRand.NJdomainID, galleryRand.NJgalleryIMG FROM NJlinkcatsubgal INNER JOIN NJcategoriesSUB ON NJlinkcatsubgal.NJcatSUBID = NJcategoriesSUB.NJcatSUBID INNER JOIN (SELECT NJgallery.* FROM NJgallery ORDER BY Rand()) AS galleryRand ON NJgallery.NJgalleryID = NJlinkcatsubgal.NJgalleryID WHERE galleryRand.NJdomainID = $domainID AND galleryRand.NJgalleryDELETE = 2 GROUP BY NJcategoriesSUB.NJcatSUBTITLE");
$rsGALLERYSUBCS->execute();
?>
Here's our tables and relevant fields:
NJgallery - NJgalleryID, NJgalleryIMG, NJdomainID
NJcategoriesSUB - NJcatSUBID, NJcatSUBTITLE
NJlinkcatsubgal - NJlinkcatsubgalID, NJcatSUBID, NJgalleryID (this is the link table between the gallery and the categories)
...is Rand() valid?
Hope you can clarify this one.
Appreciate any help offered.