Oracle external connections (key points)

Source: Internet
Author: User

In the previous articleArticleIn the internal connection discussion, we used the self-connection to find out the names of all people and their superiors. However, there is a problem: King is the boss of the entire Organization and he has no superiors, no king is displayed in the query result. We hope that such a person will be displayed in the results, and the corresponding boss will be blank. For such requirements, we can useExternal Connection.

External ConnectionDivided:Left Outer Join, right outer join, and full outer join.

UseLeft Outer JoinImplementation:

You can also use Outer right connection Implement this query:

Query results of left Outer Join or right Outer Join = results of inner join + a combination of records that cannot be matched in the matching table and a null record.

LearningAll external connectionsBefore that, let's take a look at the data in the following two tables:

We can see that there are no employees in Department 40, and no department has been assigned to employee zhangsan. We use left Outer Join firstQuery the ing between the owner name and the department name:

It can be seen that only the names of all departments are queried for the left outer join, and the names of all departments are not queried. You can useAll external connectionsSolve this problem:

We can see that the full outer connection not only queries employees who have not assigned a departmentZhangsan, You can also query departments without employeesOperations.

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.