+-------------------------+---------+
| switch | port_no |
+-------------------------+---------+
| 00:00:00:00:00:00:00:02 | 3 |
| 00:00:00:00:00:00:00:01 | 2 |
| 00:00:00:00:00:00:00:01 | 1 |
| 00:00:00:00:00:00:00:02 | 1 |
| 00:00:00:00:00:00:00:04 | 2 |
预期输出
+-------------------------+---------+
| switch | port_no |
+-------------------------+---------+
| 00:00:00:00:00:00:00:02 | 3,1 |
| 00:00:00:00:00:00:00:01 | 2,1 |
| 00:00:00:00:00:00:00:04 | 2 |
答案 0 :(得分:0)
我通过使用GROUP_CONCAT函数得到了预期的输出。
select switch,GROUP_CONCAT(port_no) from sla group by switch;