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

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

猜你喜欢

转载自www.cnblogs.com/Skate0rDie/p/12912117.html
今日推荐