Oracle Multi-Table query

Source: Internet
Author: User

Multi-Table Query

1.1 Internal Connection
The INNER JOIN keyword is typically used to specify an inner join, inner can be omitted, and the default represents an inner join. The query results contain only rows with equal values for the public fields of the two tables, which can be any of the columns in the two tables

1.2 External connection Query
Includes left outer connection, right outer join, full outer connection

(1) LEFT OUTER JOIN
The result set includes rows that meet the join criteria specified after on after two tables are connected, and all rows in the left table of the JOIN keyword that satisfy the criteria for the search, and if a row in the left table does not have a matching row in the right table, then all the selection columns of the right table are null in the result.

(2) Right outer join
Is the reverse connection of the left outer connection.

(3) Fully external connection full join
The result set for a full outer join query consists of two table-joined result sets and rows that do not meet the criteria in the left table and the right table.

The following is a multi-table query using the EMP and Dept tables:

1  Select ename,dname 2  from EMP 3 where ename='SMITH'

Execution Result:

Change to:

1 Select ename, (selectfromwhere deptno=  Division    2  from EMP 3 where ename='SMITH

If you do not know that Smith is in department number 20th, you will change to

1  Select ename, (selectfromwhere deptno=(select from where ename='SMITH' as Department   

Execution Result:

Multi-Table Query

1. Internal connection
The INNER JOIN keyword is typically used to specify an inner join, inner can be omitted, and the default represents an inner join. The query results contain only rows with equal values for the public fields of the two tables, which can be any of the columns in the two tables

1  Select enme,dname 2  from emp,dept 3 where Emp.deptmo= and Emp.ename='SMITH'

2. External connection

Oracle Multi-Table 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.