Learn SQL join, inner join, and outer join

Source: Internet
Author: User
For example:

Table A have 12 (8 + 4) entries, 8 entries have valid relation with B
Table B have 80 (77 + 3) entries, 77 entries have valid relation with.

Then the return amount of join is:
Cross join: 12*80
Inner join: 77
Full outer join: 77 + 4 + 3
Left Outer Join: 77 + 4
Right outrer join: 77 + 3

Inner joinCode as the following:

Select * From A, B where a. categoryid = B. categoryid;
Equals:
Select * from a inner join B on A. categoryid = B. categoryid;

Outer JoinCode as the following

Select * from a full (left/right) Outer Join B on a on A. categoryid = B. categoryid;

Left/right Outer Join Claus specificMSSQL:
Select * From A, B where a. categoryid * = bcategoryid;
Elect * From A, B where a. categoryid = * B. categoryid;

Left/right Outer Join Claus specificOracle:
Select * From A, B where a. categoryid = B. categoryid (+ );
Select * From A, B where a. categoryid (+) = B. categoryid;

Good resources:
Http://www.w3schools.com/ SQL/SQL _join.asp
Http://www.techonthenet.com/ SQL /joins.htm

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.