In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article will explain in detail how to deal with the MySQL field. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.
How to deal with the uniqueness of multiple fields?
Scenario
There is a table in which there are multiple fields that need to be unique and cannot be repeated, otherwise the data will be repeated and cannot be inserted.
Traditional practice
Directly add a unique index to multiple fields, simple and rough
The present practice
Add a new field with a unique index, so that you don't have to add too many unique indexes insert into news (new_title, new_abstr, new_code) values ('you are good', 'who am I', MD5 ('you are good', 'who am I')) data exists, update, do not exist, insert how to deal with it?
Scenario
There is a table in which there can be no duplicate records, update the records if they exist, and insert them if they do not exist.
Traditional practice
Query select first, update if it exists, and update if it doesn't exist
The present practice
Mysql has a special way to write, on DUPLICATE key Updateinsert into news (new_title, new_abstr, new_code, update_time, create_time) values ('you are good', 'who am I', MD5 (CONCAT ('you are good', 'who am I')) on DUPLICATE key Updateupdate_time=now (), create_time=now () on "how to deal with MySQL fields" this article is shared here, I hope the above content can be helpful to you. So that you can learn more knowledge, if you think the article is good, please share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.