There are probably a few joins in SQL

Source: Internet
Author: User

There are probably a few joinsin SQL :

Cross Join

INNER JOIN

Left OUTER JOIN

Right outer join

Full OUTER JOIN

The first is based on the cross join ( Cartesian product), then the inner join, and the rows in the result set of the Cartesian product that do not conform to the join condition are removed.

The left outer join is added to the result set of the inner join and the rows that are not selected in the leftmost table are filled with NUll for each field in the right table section of the row.

The right outer join is added to the result set of the inner join and the rows that are not selected in the left table are filled with NULL padding.

SQL JOIN usage full version

I. meaning of the various joins

There are probably a few joinsin SQL :

Cross Join

INNER JOIN

Left OUTER JOIN

Right outer join

Full OUTER JOIN

The first is based on the cross join ( Cartesian product), then the inner join, and the rows in the result set of the Cartesian product that do not conform to the join condition are removed.

The left outer join is added to the result set of the inner join and the rows that are not selected in the leftmost table are filled with NUll for each field in the right table section of the row.

The right outer join is added to the result set of the inner join and the rows that are not selected in the left table are filled with NULL padding.

outer means "there is no line on the association."

II. old style and standard notation:

1.INNER Join Code as the following:

Select * from a A, b b where A.categoryid = B.categoryid;

Equals:

Select * from a a inner joins b b on a.categoryid = B.categoryid;

2.OUTER Join Code as the following

SELECT * from a a full (left/right) outer join b b to a on a.categoryid = B.categoryid;

Equals::

Select * from a A, b b where A.categoryid *= B.categoryid;

Select * from a A, b b where A.categoryid =* B.categoryid;

Iii. examples

Table A has a (8+4) entries, 8 entries has valid relation with B

Table B has a (77+3) entries, and the entries has valid relation with A.

Then the return amount of joins is:

Cross join:12*80

Inner join:77

Full outer join:77+4+3

Left outer join:77 + 4

Right Outrer join:77 + 3

There are probably a few joins in SQL

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.