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、organization_id1、organization_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
关于mysql多行转单行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4650744/