How to write an SQL query statement in MySQL

Source: Internet
Author: User

I am a cainiao

Table A has an ID field, and table B also has an ID field.

Table A does not exist and all records in Table B need to be filtered out.

(1) Select * From t_website_notemp where id not in (select ID from t_website );

 

(2) Select t_website_notemp. * From t_website_notemp left join t_website on t_website_notemp.id = t_website.id where t_website.id is null;

 

(3) Select * From t_website_notemp ID where not exists (select ID from t_website );

 

As for the specific performance, it cannot be said that nobody is absolutely high. It should be related to the data table size and so on.

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.