Summary of MySQL Delete Problems

Source: Internet
Author: User

Internal issues related to the MySQL database

Cause Delete from table where Col not in (select Col from Table group by XX)

An error is reported.

What we need to do is

CopyCodeThe Code is as follows: Create Table TMP selete Col from Table group by xx;
Delete from table where Col not in (select Col from TMP );
Drop table TMP;

Today, when developing your own project, you need to import the original data of the project to the new system. In this process, some dirty data is generated.

We need to delete this dirty data. During the deletion process, the delete SQL statement that I wrote cannot be executed. I don't know why, so I can execute the same statement.

Select is fine.

For example:
Delete from student a where a. ID in (1, 2 );()
Select a. * from student a where a. ID in (1, 2 );()
Why?
Result processing:

Delete: The operation is successful without alias when writing a table!

For example:

Delete from student where ID in (1, 2 );()
MySQL version: 5.1.30-Community-Log

This is a small problem encountered during development.

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.