SELECT p.cat_name as par_name,p.cat_desc as p_desc, c.cat_desc as s_desc, c.cat_name, c.cat_image, c.cat_id as subID from shop_cats p, shop_cats c where c.cat_parent=p.cat_id and c.cat_parent= 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 '' at line 1