sql表中插入数据,我要向A表中插入数据,其中一部分列的数据是来自B表另一部分列是固定值这时应该怎么写

2024-11-28 16:21:27
推荐回答(2个)
回答1:

insert into A(UserName ,SJ,Sex,IsStop,Kind,Jurisdiction,Post,JB,Logins,zAddDate,zDelFlag,JC)
select [列 0],[列 1]'0','0','0','0','256',[列 2],'0','2012-05-15 09:04:04.043','0','第十届'
from B where [列 1] not in (select sj from A)

还有,你的两组列的数量不一致。

回答2:

insert into A(UserName ,SJ,Sex,IsStop,Kind,Jurisdiction,Post,JB,Logins,zAddDate,zDelFlag,JC)
select [列 0],[列 1],'0','0','0','0','256',[列 2],'0','2012-05-15 09:04:04.043','0','第十届'
from B where [列 1] not in (select sj from A)
中间少了逗号