对匹配行进行分组并添加新的空白行
我在 MYSQL 中有一个选择查询输出,如下所示:
Col 1 | Col2 |
---|---|
Fruit | Orange |
Fruit | Apple |
Fruit | Banana |
Vegetable | Potato |
Vegetable | Onion |
我希望对第 1 列中的匹配行进行分组,如果它们这样做,我想将该列设为空白并创建一个新行,预期输出如下:
Col 1 | Col2 |
---|---|
Fruit | |
Orange | |
Apple | |
Banana | |
Vegetable | |
Potato | |
Onion |
有人可以帮我解决以下问题吗? 参考
I have a select query output in MYSQL as below:
Col 1 | Col2 |
---|---|
Fruit | Orange |
Fruit | Apple |
Fruit | Banana |
Vegetable | Potato |
Vegetable | Onion |
And I am looking to group matching rows in column 1, and if they do, I want to make that column blank and create a new row, expected output as below:
Col 1 | Col2 |
---|---|
Fruit | |
Orange | |
Apple | |
Banana | |
Vegetable | |
Potato | |
Onion |
Can someone help me with below please?
Reference
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定你想做什么,但是你看过 mySQL 的 GROUP_CONCAT() 函数吗?
https://dev.mysql.com/ doc/refman/8.0/en/aggregate-functions.html#function_group-concat
I'm not sure what you want to do, but have you looked at the GROUP_CONCAT() function of mySQL?
https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_group-concat