1、union和union all 将两个表直接纵向合并。
2、对于两个表中重复的行,union取其中一个,union all都会显示
3、union和union all直需要保证两个表的列数相同,列名可以不同。
with t as ( select requester_id,accepter_id from request_accepted union all select accepter_id,requester_id from request_accepted ) select requester_id id,count(*) num from t group by requester_id order by num desc limit 1;
原文:https://www.cnblogs.com/hugrice/p/14805995.html