我有用于存储产品价格信息的表,该表看起来类似于(没有主键)
no name price date 1 paper 1.99 3-23 2 paper 2.99 5-25 3 paper 1.99 5-29 4 orange 4.56 4-23 5 apple 3.43 3-11
现在,我想选择表中“名称”字段多次出现的所有行。基本上,我希望查询返回前三行。
我试过了:
SELECT * FROM product_price_info GROUP BY name HAVING COUNT(*) > 1
但我收到一条错误消息:
列“ product_price_info.no”必须出现在GROUP BY子句中或在聚合函数中使用
SELECT * FROM product_price_info WHERE name IN (SELECT name FROM product_price_info GROUP BY name HAVING COUNT(*) > 1)