各位高人!两表合一表问题,万望赐教! (50分)

  • 主题发起人 主题发起人 无名小兵
  • 开始时间 开始时间

无名小兵

Unregistered / Unconfirmed
GUEST, unregistred user!
请问,如何能将表1、表2中的数据以如下格式添加到表3中去。
Table1
A B C
张三 001 男
李四 002 女
王五 003 男
--------------------------------
Table2
A B C
张三 380 处长
李四 220 科长
王五 410 局长
--------------------------------
Table3
A B C D E
张三 001 男 380 处长
李四 002 女 220 科长
王五 003 男 410 局长
---------------------------------
 
在table3的sql中
用如下语句:
select table1.a,table1.b,table1.c,table2.b,table2.c from table1,table2
where table1.a=table2.a
 
insert into table3
select table1.a,table1.b,table1.c,table2.b,table2.c from table1,table2
where table1.a=table2.a
 
加一句:
delete from table3
insert into table3
select table1.a,table1.b,table1.c,table2.b,table2.c from table1,table2
where table1.a=table2.a

 
后退
顶部