一、INSERT INTO IF EXISTS 具体语法:
INSERT INTO table(field1, field2, fieldn) SELECT ‘field1‘, ‘field2‘, ‘fieldn‘ FROM DUAL WHERE NOT EXISTS(SELECT field FROM table WHERE field = ?);
二、例子说明(DUAL是虚拟表)
INSERT INTO card(cardno, cardnum) SELECT ‘111‘, ‘100‘ FROM DUAL WHERE NOT EXISTS(SELECT cardno FROM card WHERE cardno = ‘111‘);
INSERT INTO card(cardno, cardnum) SELECT ‘222‘, ‘200‘ FROM DUAL WHERE NOT EXISTS(SELECT cardno FROM card WHERE cardno = ‘222‘);