连接查询+分组。 SELECT a.*, b.countif FROM `product` AS a JOIN ( SELECT NAME, merchant, count(*) AS countif FROM product GROUP BY NAME, merchant ) AS b ON b.NAME = a.NAME AND b.merchant = a.merchant;
连接查询+分组。