MySQL Judge field value to determine whether to insert a new record

Source: Internet
Author: User

Today, there is a new requirement to ensure that duplicate records are not inserted in a single table.

That is, ensure that the value of a field in each record is not duplicated.

Here is the SQL statement I gave:

 //  insert  into  select   Insert the value 1, insert the value 2, insert the value 3  from   DUAL  where  not  Span style= "COLOR:RGB (128, 128, 128); >exists   select  Span style= "COLOR:RGB (128, 128, 128); >*  where  The name of the table. Field 3 =  Insert value 3 
)

If the table. Verify field '! = ' parameter, a new record is inserted.

Reference documents:

The MySQL record does not exist when the insert record exists then the update implementation method

How can I tell if duplicate data for a specified field is not inserted in MySQL? (four methods of the post, the test found are not available or bad use.) )

Related Article

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.