How to solve the problem of duplicate mysql database IDs that cannot be deleted _ MySQL

Source: Internet
Author: User
Solution for duplicate mysql database IDs that cannot be deleted bitsCN.com

How can I delete a duplicate mysql database id?

Since I haven't engaged in databases for a long time, I forgot a lot about SQL statements.

Recently, this is only because Mysql is used in the backend of the server to store data,

To make online time statistics, the server must record the online status of users in some time periods.

In fact, implementation is not very difficult, but when there are multiple lines, it may involve writing data to the database from multiple servers. at this time, if

It is very difficult to determine the id through the upper layer. Therefore, the id should be updated automatically.

For example, if Column a is defined as unique and the value is 1, the following statements have the same effect, that is, once the entry and exit records contain a = 1, directly update c = c + 1 without executing c = 3.

1 insert into table (a, B, c) values (1, 2, 3) on duplicate key update c = c + 1;

1 update table set c = c + 1 where a = 1;

It is also worth mentioning that this statement is in mysql, but not in standard SQL statements.

BitsCN.com

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.