In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-11 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.