mysql 如何根据两列去重 mysql两列相加_mysql 如何根据两列去重

 

 如图所示,需求是我想把两列叠加起来或拼接起来,然后用group by 去重,搜的都是concat ,或group_concat ,或sum函数,不符合需求;

后来请教同事,B哥,union 函数;

mysql 如何根据两列去重 mysql两列相加_mysql 如何根据两列去重_02

 

 符合需求。

union 函数还自动去重,union all 是不去重的。