Database for internal and external connections, self-connected __ Database

Source: Internet
Author: User

Internal connections:

All records that meet the criteria will appear in the result.

Select,dept.addr from emp,dept where


Select dept.addr from emp INNER JOIN dept on

The above two kinds of writing are OK. The second type is formal.

The above SQL is an equivalent connection. In addition to the equivalent connection, there are also non-equivalent connections.

Outer joins:

Records that do not meet the criteria can also appear in the result. The left connection indicates that all the records of the table on the left appear in the result, regardless of whether the condition is met, and that the right connection represents the records of the table on the right that all appear in the result.

MySQL does not support full join. Supports LEFT join and right join. So you can simulate the result of a full join by using the result of the left join in union ALL on the right join.

The table on the left is called the primary table, and the table on the right is called from the table.

In an outer join, all the records for the primary table will be displayed.


The self connection is to say a table that connects to itself.

Select as ' current category ', as ' parent category '

From the tree T1 the left join the T2 on

The above example is the self connection.

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: 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.