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 'order by A.stt,A.id desc' at line 1syntax error: select A.id,A.luotxem,A.tenvi,A.tenkhongdau,A.thumb,A.photo,A.giaban,A.giagoc,A.thoigianbaohanhvi,A.masp,A.motavi,A.spmoi,A.spbanchay,A.khuyenmai,A.noibat,(select photo from table_hinhsp where hienthi=1 and id_sp=A.id order by stt,id desc limit 0,1) as subphoto from table_product as A where A.hienthi=1 and id_danhmuc='' and id <> '' and id_list = order by A.stt,A.id desc