Oracle Connection Query

Source: Internet
Author: User

An inner join (inner join), an outer join (outer join) has been learned in SQL Server, and an outer join is divided into a left outer join (outer join) and
Right outer join (outer join). An outer join between two tables or several tables in Oracle is represented by a (+).

Code Demo: Please check out the employee's name, department, work, salary, salary is more than 2000 yuan.
Because the department name is in dept, the other information in the EMP table requires an inner join to complete.

Sql> SELECT e.ename,e.job,e.sal,d.dname  2 from  emp e,dept d  3  WHERE e.deptno=d.deptno  4  and e.sal>2000;


You can also use an inner join in the SQL/92 standard:

Code Demo: INNER JOIN

SELECT e.ename,e.job,e.sal,d.dname from EMP e INNER joins DEPT D on E.deptno=d.deptnowhere e.sal>2000;


In this inner join, the keyword inner can be omitted.

Code Demo: Find out the employee's name and salary under each department. The EMP table uses foreign key deptno to refer to the Deptno in the Dept table,
In the Dept table, if there are no employees in some departments, an inner join will not be able to display the department with no employees, so the outer join must be based on the Dept table.

Sql> SELECT e.ename,e.job,e.sal,d.dname  2 from  EMP E, DEPT d  3  WHERE  e.deptno (+) =d.deptno  4  

Code parsing:
(+): Oracle-specific connector, which appears on the left side of the right outer join, appears on the right to refer to the left outer join.

You can also use the SQL/92 standard notation:
Code Demo: Outer JOIN

SELECT E.ename,e.job,e.sal,d.dname from EMP e right OUTER joins DEPT D on E.deptno=d.deptno;


Here right OUTER join, the keyword OUTER can be omitted.

Oracle Connection Query

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.