Oracle database Connection Query SQL statement _oracle

Source: Internet
Author: User
Inner joins (inner join).
Outer joins:
Fully connected (full join), left join (left join), right join.
Cross join (cross join).
An outer join is not the same as an inner join, and the query results returned by an outer join contain not only rows that qualify, but also the left table (left outer join), the right table (the right outer join), or all the data rows in the two join tables (all outer joins) that are not eligible.
1. Left-side [outer] Join
A LEFT outer join is a combination of all the data from the left table to each data in the right table, with the result in addition to the data in the connection, and the data in the left table that does not meet the criteria, and the null value in the corresponding column in 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 connection (right-hand [outer] join)
A right outer join is a combination of all the data in the right table with each data in the left table, with the result in addition to the data in the inline connection, the data that does not meet the criteria in the right table, and the null value in the corresponding column in 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. All outer joins (full [outer] join)
A full outer join is a combination of all the data in the left table with each data in the right table, with the result in addition to the data in the inner connection, two tables that do not meet the criteria, and a null value in the left table or the corresponding column in the 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-connect (cross join)
A cross join does not take a WHERE clause, which returns the Cartesian product of all rows of data in the two tables that are connected, and the number of rows returned to the result set equals the number of rows in the first table that match the query criteria multiplied by the number of rows in the second table that match the query criteria.
The SQL statement is as follows:
SELECT * FROM mt_pb_org o cross join Mt_pb_orgframe F;

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.