DB2 internal connection query and external connection Query

Source: Internet
Author: User
Tags db2 date

DB2 internal connection query returns the data rows in the connection table that meet the connection conditions and query conditions. The following describes the methods of DB2 internal connection query for your reference.

DB2 inner join query ):

There are two types of internal DB2 connection queries: explicit and implicit. data rows in the connection table that meet the connection conditions and query conditions are returned. The so-called chain table is the intermediate table formed by the database for query ).

For example, the following statements 3 and 4 have the same results.
Statement 3: Implicit inner join without inner join. The intermediate table is the Cartesian product of the two tables.
Select o. ID, O. ORDER_NUMBER, C. ID, C. NAME
FROM MERs C, ORDERS O
Where c. ID = O. CUSTOMER_ID;

Statement 4: The displayed inner join is generally called an inner join. The intermediate table is the Cartesian product of the two tables filtered by the ON condition.
Select o. ID, O. ORDER_NUMBER, C. ID, C. NAME
FROM MERs c inner join orders o on c. ID = O. CUSTOMER_ID;
Query results of statements 3 and 4:

Outer join ):

The external connection not only returns data rows that meet the connection and query conditions, but also some rows that do not meet the conditions. Outer join is divided into three types: left outer join), right outer join (right outer join), and full outer join (full outer join ).
All three return data rows that meet the connection condition and query condition, that is, internal connections. The differences are as follows:
The left Outer Join also returns the rows in the left table that do not meet the query conditions.
The right Outer Join also returns the data rows in the right table that do not meet the query conditions.
The Outer Join Operation also returns the rows in the left table that do not meet the query conditions and the rows in the right table that do not meet the query conditions. The total outer join is actually a mathematical collection of the upper left Outer Join and the right Outer Join.) that is, "Total outer = left outer UNION right Outer Join ".
Note: The LEFT table is the table on the LEFT of the "left outer join)" keyword. The right table is of course the right table. Among the three types of external connections, the OUTER keyword can be omitted.

Implementation of DB2 date format change

Basic knowledge of DB2 Date and Time

Manually analyze the DB2 SQL Execution Plan

Introduction to DB2 SQL Execution Plan Monitoring

DB2 event monitoring command

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.