You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ') and type='san-pham' order by id desc' at line 1syntax error: select * from table_tags where id IN (select id_tag from table_protag where id_pro=) and type='san-pham' order by id desc