MySQL links inside and outside

Source: Internet
Author: User

Outer coupling: It is divided into the outer left junction and the outer right junction.

The left junction A, B table means that all the records in table A and the joined fields in table B match the junction field of Table A to the record set formed by those records of the join condition, and note that the final record assembly includes all records of Table A.

The result of the right junction A, B table and the left junction B, a result is the same, that is to say:

Select a.name b.name from A left Join B on a.id=b.id

and select A.name b.name from B right Join A on b.id=a.id executes the same result.

Full junction: All records of a field with a junction relationship in two tables are taken out of a junction that forms a recordset (this does not need to be remembered, as long as the fields of the table mentioned in the query are taken out, regardless of whether they meet the join condition, and therefore not significant).

No coupling: Do not explain, is not the use of the link function Bai, there is a self-coupling argument.

Here I have a relatively simple memory method, the difference between the internal and external connection is that the inner join will remove all non-conforming records, and the outer joins retain some of them. The difference between a left and right junction is that if you use a left junction B then all the records in a will remain in the result, and at this point B only records that match the junction condition, and the right junction is the opposite, it will not be confused.

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.