Sorry, I've updated this to:
<?php
$rsGALLERYSUBCS = new WA_MySQLi_RS("rsGALLERYSUBCS",$csdbmysqli,20);
$rsGALLERYSUBCS->setQuery("SELECT NJlinkcatsubgal.NJcatSUBID, NJcategoriesSUB.NJcatSUBTITLE, galleryRand.NJgalleryID, galleryRand.NJdomainID, galleryRand.NJgalleryIMG, galleryRand.NJgalleryTITLE FROM NJlinkcatsubgal INNER JOIN NJcategoriesSUB ON NJlinkcatsubgal.NJcatSUBID = NJcategoriesSUB.NJcatSUBID INNER JOIN (SELECT NJgallery.* FROM NJgallery ORDER BY RAND()) AS galleryRand ON NJlinkcatsubgal.NJgalleryID = galleryRand.NJgalleryID WHERE galleryRand.NJdomainID = $domainID AND galleryRand.NJgalleryDELETE = 2 GROUP BY NJcategoriesSUB.NJcatSUBTITLE");
$rsGALLERYSUBCS->execute();
?>
...which has removed the syntax error but the images aren't displaying in a random order, despite there being more than one image in each of the categories?
Thanks.
NJ