The difference between Oracle inner JOIN, left JOIN, right join,

Source: Internet
Author: User

Organize the inner join, left JOIN, right join,

Two main tables: dept, EMP
One is the department, one is the employee table structure is as follows:


These two tables dept is the primary table EMP is the child table, the associated column is deptnodept performance has data

EMP Performance has data

Inner join means that the inside connection is all the matching information.

Sql>select E.empno,e.ename,e.job,d.deptno,d.dname
From EMP e innerjoin dept D on E.deptno=d.deptno E.empno;

Results of the query:


Left join means to include all records on the left table, all matching records on the right, and empty if not.

Sql>select E.empno,e.ename,e.job,d.deptno,d.dname
From EMP e leftjoin dept D on E.deptno=d.deptno E.empno;
Explain SQL: The left side of this SQL statement is the EMP table left connection results query the EMP all records, and then according to the left table match the right table dept all records
The query results are as follows:


Right join means to include all records on the right side of the table, match the records on the left table, and empty if not.

Sql>select E.empno,e.ename,e.job,d.deptno,d.dname
From EMP e rightjoin dept D on E.deptno=d.deptno E.empno;
EXPLANATION SQL: This SQL statement EMP on the left, dept on the right, and then we use the right connection, to find out the right table all the data

Full join fully connected means that all records of the left and right table are displayed.

Sql>select E.empno,e.ename,e.job,d.deptno,d.dname
From EMP e fulljoin dept D on E.deptno=d.deptno E.empno;
Explain SQL: This SQL statement uses the full join to query out all the values of the left and right tables.
Query Result:


Introducing Oracle + connectivity and instructions

+ Right connection on left

Sql>select E.empno,e.ename,e.job,d.deptno,d.dname
From EMP e,dept D where E.deptno (+) =d.deptno to E.empno;
Query Result:


+ Left connection on right

Sql>select e.empno,e.ename,e.job,d.deptno,d.dname from emp e,dept D where E.deptno=d.deptno (+) by E.empno;
Query Result:

The difference between Oracle inner JOIN, left JOIN, right join,

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.