例子1:
INSERT INTO T_File_Policy (ID,pcName) SELECT 2867, 'IBM' FROM dual WHERE not exists (select * from T_File_Policy where T_File_Policy.ID = 2867);
例子2:
m_SQL.Format("INSERT INTO T_File_Policy select 0,'%s','%s','%s','%s',%d,%d,'%s',%d,%d,'%s','asd' from dual where not exists (select ID from T_File_Policy where T_File_Policy.taskName = '%s' and T_File_Policy.pcName = '%s')",/
theFileName,strFilePath,m_tempPcName,theIP,0,1,/
strSendTime,nRunType,nNotice,strNotice,theFileName,m_tempPcName,theFileName,m_tempPcName);
例子3:
insert into T_Del_List (vProgramName,VPcName,Flag) select 'fffffffffffffffffffffff|00:00:00-23:59:59','192.168.100.100',2 from dual where not exists (select ID from T_Del_List where VProgramName = 'fffffffffffffffffffffff|00:00:00-23:59:59' and VPcName = '192.168.100.100' and Flag = 2)
第一个SELECT后面跟着的是插入的内容.
mysql在插入记录前先检查记录是否存在:
最新推荐文章于 2022-07-23 12:52:08 发布