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