hn_lijia

导航

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');

posted on 2020-02-27 16:39  hn_lijia  阅读(898)  评论(0编辑  收藏  举报