一个表中4条记录,如何查询所有可能组成的结果。
例如: 1 2 3 4 四条记录,最后组成(12),(13),(14),(23),(24),(34)
最后sql如下:
SELECT a.name as n1,b.name as n2,concat_ws('-',a.name,b.name) as n3 FROM `team` a, `team` b WHERE a.name<b.name ORDER BY a.name asc,b.name ASC