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 'AND cat2.idc=cat1.id' at line 1
SELECT cat1.id FROM cat1, cat2 WHERE cat2.id= AND cat2.idc=cat1.id