Go: internal and external connections for SQL

Source: Internet
Author: User

Reference: http://www.cuiyongjian.com/post-130.html

In Oracle SQL statements commonly used connections have internal connection (inner join), outer join (outer join), etc., including the equivalent connection, non-equivalent connection, self-connection, and the outside connection is divided into left and right connections. The default is an in-connection equivalent connection.

In order to facilitate the creation of two of the simplest tables A, B, the specific table structure see below, to analyze the difference between the inner and outer joins

Figure 1

Figure 2

Two tables to make a connection, you must have a connection field, and the Join field in table A and table B is aid and BNAMID, which illustrates the relationship between connections Figure 3

Figure 3

(1) Inner connection: Using the inner Connection (equivalent) to obtain the blue public part C, which is the DataSet C in Figure 3, the result set is as follows:

Figure 4

In fact select * from A joins B on A.aid=b.bnamid; equivalent to select * from A, where A.aid=b.bnamid;
Note: Non-equivalent connection is the main word for a range to query the data, self-connection is the main 1 of the table can be called two tables to use
(2) Outer connection: divided into left outer join (right join)

The left outer connection, the blue part of the public display, c1+ shows the yellow recordset A1, and the display statement is equivalent to the SELECT * from A, where a.aid=b.bnamid (+);

Figure 5

The right outer connection, the blue part of the public display, c1+ shows the green B1, and the display statement is equivalent to the SELECT * from A, where A.aid (+) =b.bnamid;

Figure 6

Table A and Table B are relative, the above experiment is a on the left of the case, in fact a to join B and B right join a in the case of the result set is the same.

Go: internal and external connections for SQL

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.