Fork me on GitHub
代码改变世界

表结构相同的表,且在同一数据库 数据复制

2015-06-11 20:44  freefei  阅读(717)  评论(0编辑  收藏  举报
1。表结构相同的表,且在同一数据库(如,table1,table2)

Sql :insert into table1 select * from table2 (完全复制)

           insert into table1 select distinct * from table2(不复制重复纪录)

          insert into table1 select top 5 * from table2 (前五条纪录)


DELETE dx_member FROM dx_member LEFT JOIN dx_student ON dx_member.username=dx_student.student_no WHERE dx_student.student_no IS NULL


 DELETE dx_member25 FROM dx_member25,dx_student WHERE dx_member25.username=dx_student.student_no 

username    count
003    2
04031    2
04049    2
04073    2
09783    2

206136    2
5185    2
523037    2
5380    2
54452    2
6050    2
6077    2
6379    2
6991    2
7027    3
9281    2
9290    2

 

@ https://github.com/ranmufei

校友通微信小程序

校友通微信小程序