SQL table Connection Basic syntax

Source: Internet
Author: User

SQL connections can be divided into internal, external, and cross-joins.

1. Internal connection: Inner Join the query operation lists the data rows that match the join criteria, which uses comparison operators to compare the column values of the concatenated columns.

1.1 SELECT * from Table1 as a, Table2 as B where a.id= b.id

1.2 SELECT * FROM Table1 as a inner joins Table2 as B on a.id = b.ID

  1. External connection
    2.1 Left OUTER join (simply put, left table data full display, right mismatch display null)

    SELECT * from Table1 as a left join Table2 as B on a.id = b.ID
    2.2 Right outer connection (opposite)

    SELECT * from Table1 as a right joins Table2 as B on a.id = b.ID

2.3 Full connection (when a row does not have a matching row in another table, the selection list column for the other table contains a null value.) If there are matching rows between the tables, the entire result set row contains the data values of the base table)

SELECT * from Table1 as a full outer join Table2 as B on a.id = b.ID

3. Each row in the left table is combined with all rows in the right table. Cross joins are also called Cartesian product

SELECT * from Table1 as a cross join Table2 as B Order b a.id

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

SQL table Connection Basic syntax

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.