SQL Leftist right inline full-union basic syntax

Source: Internet
Author: User
Tags join

SQL inline Syntax basic syntax (INNER join)

SELECT * FROM table 1 inner JOIN table 2 on table 1.userid= table 2.userid

SQL Inline Syntax Description: The above statement is the query Table 1 and table 22 tables, as long as the UserID field in two tables in the same line to display.

45it.com Note: The above syntax is equivalent to select * FROM table 1, table 2 where table 1.userid= table 2.userid, and the use of SQL inline, will improve a lot of efficiency.

SQL Leftist syntax basic syntax (left OUTER join)

SELECT * FROM table 1 left OUTER JOIN table 2 on table 1.userid= table 2.userid

SQL Leftist syntax Description: Displays all the rows in table 1 and displays all eligible data in table 2 to the result set, if none of the data in table 2 does not appear in the result set, and is displayed as null.

SQL Right syntax base syntax (outer join)

SELECT * FROM table 1 right OUTER JOIN table 2 on table 1.userid= table 2.userid

SQL Leftist syntax Description: Displays all the rows in table 2 and displays all eligible data in table 1 to the result set, if none of the data in the left table 1 does not appear in the result set, and is displayed as null.

SQL Total Syntax basic syntax (full outer join)

SELECT * FROM table 1 full OUTER JOIN table 2 on table 1.userid= table 2.userid

SQL Leftist syntax Description: The above SQL full-link meaning is to display table 1 and table 2 all the rows, to put it simply, is the table 1 and table 2 all the rows together, then filter out duplicate data and display in the result set.

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.