[英]mysql multiple row to single row
post_id organisation_id
1 5
2 57
3 57
4 57
5 58
6 59
7 60
8 61
8 62
9 59
11 57
12 57
4 62
无论如何选择post_id,organisation_id1,organisation_id2在一行?
由于您没有指定表格的样子以及您想要的结果,这只是猜测。
SELECT
a.post_id,
a.organisation_id,
b.organisation_id
FROM your_table a
LEFT JOIN your_table b
ON a.post_id = b.post_id AND a.organisation_id < b.organisation_id
这是你在找什么?
select post_id, group_concat(organisation_id)
from YourTable
group by post_id;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.