Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一张包含事件列表的表格。我想根据唯一值“事件”将多行中的单位值合并到一列中以进行显示。
当前数据:
Date Time Incident Unit 1/1 1200 1234 101 1/1 1200 1234 102
我想如何显示它:
Date Time Incident Unit 1/1 1200 1234 101, 102
我正在使用 mysql/php。
谢谢!
试试这个查询:
SELECT `date`, `time`, `incident`, group_concat(`unit`) from table group by `incident`
使用此查询
SELECT date, time, incident, GROUP_CONCAT(unit SEPARATOR ", ") AS unit FROM table GROUP_BY incident