MySQL 当记录不存在时插入(insert if not exists、dual )

INSERT INTO clients
(client_id, client_name, client_type)
SELECT 10345, ’IBM’, ’advertising’
FROM dual
WHERE not exists (select * from clients
where clients.client_id = 10345);

insert into cdb_shop (uid,shop) SELECT '2021','202298' from dual where not exists(SELECT * FROM cdb_shop WHERE uid = '2021');

原文地址:https://www.cnblogs.com/hn_lijia/p/12372867.html