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

两个没有任务 相同的字段的表如何合并
A表:
  spmc ,spbm
  a 01
  b 02
  c 03

B表
  spmc , spbm
  d 04
  e 05
  f 06

合成表 C:
  spmc ,spbm
  a 01
  b 02
  c 03
  d 04
  e 05
  f 06

请问这样的语名要怎么写了






 

------解决方案--------------------
SQL code
select * from a
union all
select * from b

------解决方案--------------------
select * from a
union all
select * from b
------解决方案--------------------
select * from
(
select * from a
union all
select * from b
) c
------解决方案--------------------
不去重复 union all
去重复 union

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

select * from a
union all   --加all不去重,直接union去重!
select * from b

------解决方案--------------------
select * from a 
union all
select * from b

------解决方案--------------------
探讨

消息 205,级别 16,状态 1,第 3 行
使用 UNION、INTERSECT 或 EXCEPT 运算符合并的所有查询必须在其目标列表中有相同数目的表达式。