Explain SQL statements on the left, right, and inside and outside

Source: Internet
Author: User
Internal JOIN: INNERJOIN or JOIN, which finds the data corresponding to the two tables. Outer Join: OUTERJOIN. The corresponding data is retrieved based on a table and divided into left Outer Join and right outer join. Left Outer Join: LEFTJOIN or LEFTOUTERJOIN. The corresponding data is retrieved based on a table. RIGHT outer join: RIGHTJOIN or RIGHT

Internal JOIN: inner join or JOIN to check the data corresponding to the two tables. Outer join: outer join, which identifies the corresponding data based on a table and is divided into left outer join and right outer join. Left outer join: left join or left outer join. The corresponding data is retrieved based on a table. Outer right join: right join or RIGHT

Student table
NO Name
1
2 B
3 c
4 d

Grade table
NO Grade
1 90
2 98
3 95
5 90

Inner join: The data corresponding to the search condition. No data is listed in no4.
Syntax: * from student inner join grade on student. no = grade. no
Result:
NO Name NO Grade
1 a 1 90
2 B 2 98
3 c 3 95

Left join: All data in the left table, corresponding data in the right table
Syntax: select * from student left join grade on student. no = grade. no
Result:
NO Name NO Grade
1 a 1 90
2 B 2 98
3 c 3 95
4 D

Right join: All data in the right table, corresponding data in the left table
Syntax: select * from student right join grade on student. no = grade. no
Result:
NO Name NO Grade
1 a 1 90
2 B 2 98
3 c 3 95
5 90


Full connection
Syntax: select * from student full join grade on student. no = grade. no
Result:
No name grade
1 a 90
2 B 98
3 c 95
4 d
1 a 90
2 B 98
3 c 95

Note: you cannot directly use full join in access. You must use union all to merge the left and right connections.

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.