1.如果表不存在
create table 表1 select * from 表2;
2.如果表存在
①如果兩張表結構一致
insert into 表1 select * from 表2;
②如果兩張表結構不一致
insert into 表1(字段1,字段2,...,字段n) select 字段1,字段2,...,字段n from 表2;
應用舉例:
下圖為用戶表數據。

1.將用戶表的數據復制到一張新表并命名為用戶表2;

2.將用戶表中銷量大于6的數據插入到用戶表2;

網友整理
注冊時間:
網站:5 個 小程序:0 個 文章:12 篇
網站
小程序
文章
會員