MySQL字段处理方法

来源:这里教程网 时间:2026-02-28 11:43:07 作者:

多个字段唯一性如何处理?

情景

传统做法

现在做法

insert into news(new_title, new_abstr, new_code) 
values('你是好','我是谁',MD5(CONCAT('你是好','我是谁')))

数据存在,就更新,不存在,就插入如何处理?

情景

传统做法

现在做法

insert into news(new_title, new_abstr, new_code, update_time, create_time) 
values('你是好','我是谁',MD5(CONCAT('你是好','我是谁')))
on DUPLICATE key Update
update_time=now(), create_time=now()



相关推荐