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 'a' AND country.id=profile.country AND profile.status='1' GROUP BY profile.id' at line 4