Could not successfully run query (select mountings.product_id, mountings.item_no, ifnull(mountings.description,'') as 'description', ifnull(mountings.blemish,'') as 'blemish', ifnull(mountings.luster,'') as 'luster', ifnull(mountings.metal_desc,'') as 'metal_desc', ifnull(mountings.stone,'None') as 'stone', ifnull(is_set,'') as 'is_set', mountings.create_date, ifnull(sort.category,'') as 'category', ifnull(type.type,'') as 'type', ifnull(mountings.color_desc,'') as 'color', ifnull(mountings.size_desc,'') as 'size', ifnull(mountings.shape_desc,'') as 'shape', ifnull(metal.metal,'') as 'metal', ifnull(mountings.grade_desc,'') as 'grade', ifnull(price_range.price_range,'') as 'price_range', ifnull(mounting_photos.img_path,'') as 'img_path' from mountings left outer join sort on mountings.sort = sort.id left outer join type on mountings.type = type.id left outer join metal on mountings.metal = metal.id left outer join price_range on mountings.price_range = price_range.id left outer join mounting_photos on mountings.product_id = mounting_photos.product_id where 1=1 and mountings.product_id = order by mountings.product_id, mounting_photos.photo_id) from DB: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order by mountings.product_id, mounting_photos.photo_id' at line 25