本文介绍了mysql 多行到单行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
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、organizational_id1、organizational_id2 吗?
is there anyway to select post_id, organisation_id1, organisation_id2 in a single row?
推荐答案
由于您没有指定表格的外观以及您想要的结果,这只是一个猜测.
Since you didn't specify what your table looks like and what would be the outcome that you would like, this is just a guess.
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 多行到单行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!