由於mysql不支持select into 方法,mysql怎樣將一張表的查詢結果存到另一張表中?
找了兩個方法
第一種:
create table dust select * from student;//用於復制前未創建新表dust的情況下
第二種
insert into dust select * from student;//已經創建了新表dust的情況下
----------------------------------------------------------------------
如果表結構不一樣
insert into 表1 (列名1,列名2,列名3) select 列1,列2,列3 from 表2
不同數據庫,需要在表前面加數據庫前綴,database.表名。
注意:以上測試過OK,sql語句不需要在insert后面加values。
=============================
測試語句為:insert into xx_company_templates (REL_ID,SET_TIME) select COMPANY_ID,CREATE_TIME from xx_company