MySQL left connection right connection inner connection--example

Source: Internet
Author: User

Here are two tables

Table Stu

  

Table Tech

  

  

  1. Right connection

When using the RIGHT JOIN statement query, the results are as follows:

1 SELECT stu.id,stu.name,stu.classe_name,tech.id,tech.name from Stu right JOIN tech on Stu.classe_name=tech.classe_name ;

  

As you can see from the results, the fields that are queried in the tech table are all displayed, and in the Stu table, only the corresponding fields of the same entries as the table Tech's classe_name will be displayed.

 Right connection: Returns all fields in the right table that match the criteria in the table on the left.

  2. Left connection

When querying with a left connection statement, the result is as follows:

1 SELECT stu.id,stu.name,stu.classe_name,tech.id,tech.name from Stu left JOIN Tech on Stu.classe_name=tech.classe_name;

  

As you can see from the results, the fields that are queried in the Stu table are all displayed, and in the tech table, only the corresponding fields of the same entries as the table Stu Classe_name are displayed.

  Left join: Returns all fields in the left table that match the criteria in the table to the right.

  3. Internal connection

When querying with an inner JOIN statement, the result is as follows:

1 SELECT stu.id,stu.name,stu.classe_name,tech.id,tech.name from Stu INNER JOIN Tech on Stu.classe_name=tech.classe_name ;

MySQL left connection right connection inner connection-example (GO)

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.