insert into mytab values(value1,value2,value3) where (frmwarehouse,frmwarehouse) not in (select frmwarehouse,frmwarehouse from mytab);
有点乱。insert和update混了呀方法一、 insert into 表明(列名1,列名2,....)values(数据1,数据2,.....)方法二、 insert into 表明(列名1,列名2,....) select 数据1,数据2,.... from 表名
多谢各位!我采用 insert mytab (FrmWarehouse, FrmLocation) -- values ( select 'LG07' as FrmWarehouse, '1I-08-2-0' as FrmLocation where not exists (select 1 from el_picklistusersetting where FrmWarehouse='LG07' and FrmLocation='1I-08-2-0' --) 以上sql如果去掉--会报Incorrect syntax near the keyword 'select'.类似的错误 搞得,我刚才的思路一直想用where 和 in/ not in
insert into mytab(frmwarehouse frmlocation)
select UserId frmwarehouse frmlocation from mytab;
add constraint FF unique (frmwarehouse, frmlocation );
执行这个语句,当插入的value2和value3已经存在记录中时,记录查不进去!
where (frmwarehouse,frmwarehouse) not in
(select frmwarehouse,frmwarehouse from mytab);
insert into 表明(列名1,列名2,....)values(数据1,数据2,.....)方法二、
insert into 表明(列名1,列名2,....)
select 数据1,数据2,.... from 表名
insert mytab (FrmWarehouse, FrmLocation)
-- values (
select 'LG07' as FrmWarehouse, '1I-08-2-0' as FrmLocation
where not exists (select 1 from el_picklistusersetting where FrmWarehouse='LG07' and FrmLocation='1I-08-2-0'
--)
以上sql如果去掉--会报Incorrect syntax near the keyword 'select'.类似的错误
搞得,我刚才的思路一直想用where 和 in/ not in