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 id !='' AND type='dichvu' order by stt,ngaytao desc' at line 1syntax error: SELECT ten_vi as ten,ngaytao,id,tenkhongdau,thumb,photo,mota_vi as mota,file_baogia FROM table_baiviet WHERE hienthi=1 AND id_list = AND id !='' AND type='dichvu' order by stt,ngaytao desc