insert into 表1(字段1,字段2..) select 字段1,字段2.. from 表2 where 条件1;
1、当表1=表2的时候,实现表内数据的复制
2、insert into的字段必须与select的字段匹配,否知会报错
3、由where条件的控制,可以实现多条数据,单条数据的复制
4、当你想复制部分字段,修改部分字段的值时,你会怎么做呢???
这是我的写法,可以实现上述要求。请多指教![大笑](http://static.blog.csdn.net/xheditor/xheditor_emot/default/laugh.gif)
![大笑](http://static.blog.csdn.net/xheditor/xheditor_emot/default/laugh.gif)
insert into 表1(字段1,字段2..) select 值 as 字段1,字段2.. from 表2 where 条件1;
此时复制字段2,字段1的值被修改了
insert into batch_a_detail_db(pid,day_length,used,show_type,createuser) select 133 as pid,day_length,used,show_type,17 as createuser from batch_a_detail_db where pid =122