码迷,mamicode.com
首页 > 数据库 > 详细

mysql 指定的字段如果重复(已存在),则不再插入

时间:2020-05-18 18:46:49      阅读:196      评论:0      收藏:0      [点我收藏+]

标签:style   sel   insert   font   col   exists   where   rom   判断   

insert into 表名(待插入字段1,待插入字段2,...,待插入字段n)
select
张三,1,...,袜子
from 表名 a
where not exists(select 1 from 表名 b where b.判断条件字段1=张三 and b.判断条件字段2=1 and 判断条件字段n=23531172612)

 

 

 

 

【注】 

where not exists:

如果其后查询出了结果,则该条件成立, 否则,不成立













1

mysql 指定的字段如果重复(已存在),则不再插入

标签:style   sel   insert   font   col   exists   where   rom   判断   

原文地址:https://www.cnblogs.com/Skate0rDie/p/12912117.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!