In aggregated query without GROUP BY, expression #2 of SELECT list contains nonaggregated column 'cptcolorpl_db.p.id'; this is incompatible with sql_mode=only_full_group_bysyntax error: select count(p.id) AS numrows, p.id,p.ten_vi,p.tenkhongdau_vi,p.photo,p.spmoi,p.spkm,p.spbc,p.tinhtrang,p.size,p.chatlieu,p.xuatxu,p.ri,p.color,p.masp,i.tenkhongdau_vi as tenloai, c.tenkhongdau_vi as danhmuc from table_product as p,table_product_cat as i,table_product_list as c where p.hienthi = 1 and p.id_list=c.id and p.id_cat = i.id and p.id in(0,1) order by p.stt,p.id desc