获取不同 MySQL 记录的重复
Get recurrence of different MySQL records
我想找回短信的次数最多。
示例 1:
Column1 Column2 Column3 Column4 Column5
Red Red Red White Blank
结果查询:
Red
示例 2:
Colum1 Colum2 Colum3 Colum4 Colum5
White White Red Yellow Blank
结果查询:
White
我最近遇到了类似这个问题。希望这有帮助。
select col
from
(select col1 as col from tab1
union all
select col2 as col from tab1
union all
select col3 as col from tab1
union all
select col4 as col from tab1
union all
select col5 as col from tab1) as new_table
group by col order by count(*) desc limit 1;
我想找回短信的次数最多。
示例 1:
Column1 Column2 Column3 Column4 Column5
Red Red Red White Blank
结果查询:
Red
示例 2:
Colum1 Colum2 Colum3 Colum4 Colum5
White White Red Yellow Blank
结果查询:
White
我最近遇到了类似这个问题。希望这有帮助。
select col
from
(select col1 as col from tab1
union all
select col2 as col from tab1
union all
select col3 as col from tab1
union all
select col4 as col from tab1
union all
select col5 as col from tab1) as new_table
group by col order by count(*) desc limit 1;