DB2 of the database (OUTER join), INNER join (INNER join) and Cross join

Source: Internet
Author: User
Tags joins

1, Cross join: There are two, explicit and implicit, without an ON clause, returns the product of two tables, also known as the Cartesian product, the number of returned records should be in a and B table in accordance with the record and. Explicit: SELECT [Cols_list] from a Cross Joinb where [condition] implicit: SELECT [Cols_list] from a ,b where [condition] 2, INNER join (INNER join): There are two kinds, explicit and implicit, that return rows of data in the join table that meet the join condition and query criteria, and we write the same as normal SQL. Explicit: SELECT [Cols_list] from a INNER JOINb on [condition] where [condition] implicit: SELECT [Cols_list] from a ,b where [condition] 3, outer join (OUTER join): The outer joins not only return data rows that meet the connection and query criteria, but also return some rows that do not meet the criteria. The outer joins are divided into three categories: Left OUTER join (OUTER join), right outer join (OUTER join), and full outer join (fully OUTER join). What all three have in common is that they return rows of data that meet the join criteria and query criteria (that is, inner joins). The difference is as follows: the left OUTER join also returns data rows in the left table that do not meet the criteria of the join criteria for the query. The right outer join also returns the data rows in the right table that do not meet the criteria for the join criteria. The full outer join also returns rows of data in the left table that do not meet the criteria for the join criteria, and also returns rows in the right table that do not meet the criteria for a join condition. The full outer join is actually a mathematical collection of upper left outer joins and right outer joins (removing duplicates), i.e. "all outside = left outer UNION right outside". Description: The left table is the table to the left of the "(OUTER JOIN)" keyword. The right table is, of course, on the right. In three types of outer joins, the OUTER keyword can be omitted such as: SELECT [Cols_list] from a LEFT join B on [condition] where [condition] multiple tables can be used: SELECT [Cols_ List] From a LEFT join B in [condition] inner JOIN C on [condition] where [condition] Source: http://blog.csdn.net/huoyin/articl e/details/5788265

DB2 of the database (OUTER join), INNER join (INNER join) and Cross join

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.