更新时间:2023-01-31 20:56:50
仅在一侧分组,并使用
Group on only one side and take the MIN() of the other:
MIN()
SELECT MIN(a.ID) a, b.ID b FROM mytable a JOIN mytable b ON b.text = a.text AND b.ID > a.ID GROUP BY b.ID
在 sqlfiddle 上查看.
如何在具有可传递性的MySQL联接(同一表)中选择不同的对?