插入資料a表到b表

2021-05-23 22:49:29 字數 479 閱讀 6110

insert into p_web p (p.tid,p.title,p.fileurl,p.columnid,p.columnname)(select l.tid,l.linkname,l.linkurl,'3033' as columnid from p_link l where l.columnid=337)

insert into expertinfo

(expertid,expertname,expertcode,***,enabled)

select

primarykey as expertid,

name as expertname,

'' as expertcode,

case *** when '男' then '1' when '0' then '女' end as ***,

'0' as enabled

from experttmp

case改用decode 也可以

查詢A表資料插入到B表中 sql

通常使用的插入sql語句大部分是 insert into a a,b,c values 1,2,3 4,5,6 1.同乙個資料庫,a表存在時 在一些特殊的情況下 也可以使用 insert into a a,b,c select a,b,c from b 但是需要注意的是 在這種情況中的 values...

mysql把A表資料插入到B表資料的幾種方法

web開發中,我們經常需要將乙個表的資料插入到另外乙個表,有時還需要指定匯入字段,設定只需要匯入目標表中不存在的記錄,雖然這些都可以在程式中拆分成簡單sql來實現,但是用乙個sql的話,會節省大量 下面我以mysql資料庫為例分情況一一說明 1.如果2張表的字段一致,並且希望插入全部資料,可以用這種...

從A表更新資料到B表

update select t.report 3code as a,b.report 3code as b from branch remote run t,branch b where b.branch code t.branch code set b a 將a表中的report 3code欄位更...