日期:2014-05-16  浏览次数:20809 次

求一MySql查询语句
SQL code

table a:
aid na nb
0   1  2
1   1  3
2   3  2

查询结果:
nab
1
2
3


结果为字段na和字段nb的记录去除重复后的汇总。

------解决方案--------------------
SQL code
select nab
from (
select na as nab from a
union
select nb as nab fromm a
)T
order by T.nab

------解决方案--------------------
错了
SQL code
select nab
from (
select distinct na as nab from a
union
select distinct nb as nab fromm a
)T
order by T.na

------解决方案--------------------
没有其它好方法了。