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 type='sanpham' order by id desc' at line 1syntax error: select id,ten from table_tags where id IN (select id_tag from table_protag where id_pro=) and type='sanpham' order by id desc