Mysql Multi-table connection query inner JOIN and outer join use

Source: Internet
Author: User

The meaning of join is like the English word "join", connecting two tables, roughly divided into inner connection, outer connection, right connection, left connection, natural connection. The description here is to throw out a rotten picture and insert the test data.

First of all, the classification (inner connection, outer connection, cross Connection) and connection method (as follows) are listed in this article:

A) Inner connection : Join,inner join

B) Outer connection : Left join,left outer join,right join,right outer join,union

C) Cross connect: intersect Join

Case table:

T_users:

T_department:

First type: Inner connection inner JOIN

INNER JOIN INNER JOIN is the most common connection operation. From a mathematical point of view is to find the intersection of two tables, from the angle of Cartesian product is to pick out the Cartesian product on the condition of the set of records.

There are inner join,where (equivalent connection), Straight_join,join (omit inner) four kinds of notation.

Select  from  = t.department_id

The results show that only the partial data of the on condition are common to the table A and B tables.

Second type: outer connection left join,left outer JOIN, right JOIN, right outer join, union

1) The meaning of the left join is to find the intersection of the two table A and B tables plus the remaining data from the left table . Still from the Cartesian product point of view, is to first pick out the Cartesian product on the condition of the set of records, and then add the left table a table of the remaining records (see the last three).

Select    from t_users T  Left Join  on = t.department_id

Mysql Multi-table connection query inner JOIN and outer join 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.