Oracle Database Connection query SQL statements

Source: Internet
Author: User

Inner join ).
External Connection:
Full join, left join, and right join ).
Cross join ).
The outer join and the inner join are different. The query results returned by the outer join include not only the rows that meet the conditions, but also the left table (left Outer Join) and the right table (right Outer Join) or all non-conforming data rows in two connected tables (all external connections.
1. left join (left [outer] join)
The left Outer Join combines all data in the left table with each data entry in the right table. The returned results include non-conforming data in the left table in addition to the data in the inner join, enter the null value in the corresponding column of the right table.
The SQL statement is as follows:
Select * from mt_pb_org o left join mt_pb_orgframe f on o. PB_ORGFRAMEID = f. PB_ORGFRAMEID;
Equivalent statement:
Select * from mt_pb_org o, mt_pb_orgframe f where o. pb_orgframeid = f. pb_orgframeid (+ );
2. right join (right [outer] join)
The outer right join combines all the data in the right table with each data entry in the left table. The returned results include non-conforming data in the right table in addition to the data in the inner join, enter the null value in the corresponding column of the Left table.
The SQL statement is as follows:
Select * from mt_pb_org o right join mt_pb_orgframe on o. pb_orgframeid = f. pb_orgframeid;
Equivalent statement:
Select * from mt_pb_org o, mt_pb_orgframe f where o. pb_orgframeid (+) = f. pb_orgframeid;
3. full outer join (full [outer] join)
A full outer join is to concatenate all the data in the left table with each data entry in the right table. The returned results include non-conforming data in the two tables in addition to the data in the internal join, enter the null value in the corresponding column of the Left or Right table.
The SQL statement is as follows:
Select * from mt_pb_org o full join mt_pb_orgframe o. pb_orgframeid = f. pb_orgframeid;
4. cross join)
A crossover clause without a WHERE clause returns the Cartesian product of all data rows in the two joined tables, the number of rows returned to the result set is equal to the number of rows that meet the query conditions in the first table multiplied by the number of rows that meet the query conditions in the second table.
The SQL statement is as follows:
Select * from mt_pb_org o cross join mt_pb_orgframe f;

Related Article

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.