【发布时间】:2021-05-25 01:11:33
【问题描述】:
我想在一个表中列出所有出现的重复项并按它们的 id 重新组合它们。
这是我的桌子:
+------------+----+
| name | id |
+------------+----+
| Produit 78 | 5 |
| Produit 78 | 6 |
| Produit 78 | 11 |
| Produit 69 | 12 |
| Produit 12 | 14 |
| Produit 12 | 15 |
| Produit 92 | 22 |
| Produit 92 | 25 |
我试过了:
select name, id from commande_ligne group by name having count(name) > 1;
但它只列出了第一次出现的重复项。
而我想要这样的东西:
+------------+-------+
| name | id |
+------------+-------+
| Produit 78 | 5,6,11|
| Produit 12 | 14,15 |
| Produit 92 | 22,25 |
【问题讨论】:
标签: mysql duplicates group-concat