简体   繁体   English

如果已经存在相同的条目,然后在db中编辑该条目,然后使用php或sql将其存储在db中?

[英]Editing the entry in db, if the same entry already exists and then storing it in the db using php or sql?

我有一个数据库中的表,表中包含月份列表,如果我们插入一个新行(例: JanJan是该表已经存在,那么新进入Jan应输入为Jan2如果再次出现Jan然后应该是Jan3 ,对此有什么解决方案吗?

MySQL has a special command for this - INSERT ... ON DUPLICATE KEY UPDATE . MySQL对此具有特殊的命令-INSERT ... ON DUPLICATE KEY UPDATE

PostgreSQL has a thing alike - INSERT ... ON CONFLICT ... . PostgreSQL有类似的东西-INSERT ... ON CONFLICT...。

Many other DB have the same option. 许多其他数据库具有相同的选项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM