假设我有下表:
------------------------------------ Name1 | Address1 | Name2 | Address2 ------------------------------------ AAA | Tokyo | CCCC | Brazil EEE | paris | FFFF | Cairo
我需要在sql server中进行查询才能给我两(2)列
---------------- Name | Address ---------------- AAA | Tokyo CCCC | Brazil EEE | paris FFFF | Cairo
答案 0 :(得分:1)
使用UNION ALL:
insert into final_table
select Name1 name, Address1 address from init_table
union all
select Name2 name, Address2 address from init_table;