select a.fieldl,a.aaa,a.bbb,b.aaa,b.ddd,b.eee into newtable from table1 a,table2 b where a.field1 = b.field1Where 处看你的要求了,是相等关系啊还是包含关系,还是连aaa也参加判断
加ALL。 select field1 from a union all select field1 from b
1:没有identity字段 先定义新表NewTable 使用重复行 Insert Into NewTable select * from TableA union all select * from TableB 不使用重复行 Insert Into NewTable select * from TableA union select * from TableB 2:有identity字段(indentity字段不写) 使用重复行 Insert Into NewTable(Col1,Col2..) select Col1,Col2.. from TableA union all select Col1,Col2.. from TableB 不使用重复行 Insert Into NewTable(Col1,Col2..) select Col1,Col2.. from TableA union select Col1,Col2.. from TableB
union
select field1 from b
union
select field1 from b
from table1 a,table2 b
where a.field1 = b.field1Where 处看你的要求了,是相等关系啊还是包含关系,还是连aaa也参加判断
select field1 from a
union all
select field1 from b
先定义新表NewTable
使用重复行
Insert Into NewTable
select * from TableA
union all
select * from TableB
不使用重复行
Insert Into NewTable
select * from TableA
union
select * from TableB
2:有identity字段(indentity字段不写)
使用重复行
Insert Into NewTable(Col1,Col2..)
select Col1,Col2.. from TableA
union all
select Col1,Col2.. from TableB
不使用重复行
Insert Into NewTable(Col1,Col2..)
select Col1,Col2.. from TableA
union
select Col1,Col2.. from TableB
union
select field1 from b