日期:2014-05-18  浏览次数:20665 次

多条sql查询语句查出来的字段都是一样的 如何将数据合并
两条SQL语句可能前面一条没加条件查了个总表,第二个查了一个时间段的
select a,b from test 

select a,b from test where c=1

用查询分析器查出来时分开来的,我是想只要一个列名,数据统计到一起去,如何做到?求高人指点!!!!!!!

------解决方案--------------------
select a,b from test
union
select a,b from test where c=1

------解决方案--------------------
SQL code


select a,b from test   
union--去掉上下两个语句重复的数据行
select a,b from test where c=1


select a,b from test   
union all--不去掉上下两个语句重复的数据行,保留两语句的所有结果航
select a,b from test where c=1

------解决方案--------------------
探讨
SQL code



select a,b from test
union--去掉上下两个语句重复的数据行
select a,b from test where c=1


select a,b from test
union all--不去掉上下两个语句重复的数据行,保留两语句的所有结果航
select a,b from test where c=1


……