INSERT INTO `ig_view_tovar_res` (`IP`,`id_tovar`,`date`,`cols`,`nIP`) SELECT igv.IP,igv.id_tovar,igv.`date`,count(igv.id_tovar) as _cols ,`nIP` FROM `ig_view_tovar` igv where igv.`date` >= '2017-09-22 00:00:00' and igv.`date` <= '2017-09-22 23:59:59' group by igv.IP,igv.id_tovar