You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'GROUP BY fssc_id ORDER BY pl_id DESC, fssc_dateadded DESC LIMIT 0,10' at line 23You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'GROUP BY fssc_id ORDER BY pl_id DESC, fssc_dateadded DESC LIMIT 0,10' at line 23SELECT forsale_staticcaravans.fssc_id,forsale_staticcaravans.fssc_model, forsale_staticcaravans.fssc_desc, forsale_staticcaravans.fssc_year,IF(pl.pl_id,1,0) AS pl_id, COUNT(forsale_images.img_ad) AS imgCount, opt_counties.county_desc, opt_areas.area_desc, forsale_images.img_id, manufacturers.manu_desc, forsale_staticcaravans.fssc_price, forsale_staticcaravans.fssc_berth FROM (forsale_staticcaravans, opt_counties, opt_areas ) LEFT JOIN premium_listing AS pl ON forsale_staticcaravans.fssc_id = pl.pl_advert AND pl_type = 'Static' AND pl_expiry >= CURDATE() LEFT JOIN forsale_images ON forsale_images.img_ad = forsale_staticcaravans.fssc_id AND forsale_images.img_carvan_type = 2, manufacturers WHERE forsale_staticcaravans.fssc_status = 3 AND opt_counties.county_id = forsale_staticcaravans.fssc_county AND opt_areas.area_id = forsale_staticcaravans.fssc_area AND manufacturers.manu_id = forsale_staticcaravans.fssc_manufacturer AND forsale_staticcaravans.fssc_manufacturer = GROUP BY fssc_id ORDER BY pl_id DESC, fssc_dateadded DESC