Basic Syntax of SQL left-and right-join inline full join

Source: Internet
Author: User
SQL inline syntax basic syntax (innerjoin) SELECT * FROM Table 1innerjoin table 2on table 1. userid table 2. useridsql inline syntax description: The preceding statement is used to query two tables, table 1 and table 2. If the userid fields in the two tables are the same, a row is displayed. 45it.com Note: The preceding syntax is equivalent to select * from table 1 and table 2.

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 preceding statement is used to query two tables, table 1 and table 2. If the userid fields in the two tables are the same, a row is displayed. 45it.com Note: The preceding syntax is equivalent to select * from table 1 and table 2.

SQL inline syntax (inner join)

SELECT * FROM table 1 inner join table 2 on table 1. userid = TABLE 2. userid

SQL inline syntax description: The preceding statement queries two tables, table 1 and table 2. If the userid fields in the two tables are the same, a row is displayed.

45it.com Note: The above syntax is equivalent to select * from table 1, Table 2 where Table 1. userid = TABLE 2. userid. If SQL inline is used, a lot of efficiency will be improved.

SQL left join syntax (left outer join)

SELECT * FROM table 1 left outer join table 2 ON table 1. userid = TABLE 2. userid

SQL left join syntax description: displays all rows in table 1, and displays all data in table 2 that meet the conditions in the result set, if any of the non-conforming data in table 2 is not displayed in the result set, it is displayed as null.

SQL right join syntax (right outer join)

SELECT * FROM table 1 right outer join table 2 ON table 1. userid = TABLE 2. userid

SQL left join syntax description: displays all rows in table 2, and displays all data that meet the conditions in table 1 to the result set, if none of the data in the left table 1 is displayed in the result set, it is displayed as null.

Full outer join)

SELECT * FROM table 1 full outer join table 2 ON table 1. userid = TABLE 2. userid

SQL left join syntax description: The above SQL full join means to display all rows in tables 1 and 2. Simply put, it means to combine all rows in tables 1 and 2, then, duplicate data is filtered out and displayed 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.