select main_id, attr_value from record_attr where attr_lang='en' and main_id in () order by attr_value: 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 attr_value' at line 1