SQL Server database Multi-table federated query

Source: Internet
Author: User
Tags joins

INNER JOIN: (INNER join)
Inner joins use comparison operators to match rows in two tables based on values in the universal columns of each table
(1) SELECT ... From table 1INNER JOIN table 2ON ...
SELECT S.sname,c.courseid,c.score
From score as C
INNER JOIN Students as S
On c.studentid = S.scode
(2) SELECT ... From table 1, table 2WHERE ...
SELECT Students.sname, Score.courseid, Score.score
From Students,score
WHERE Students.scode = Score.studentid

Outer joins:
(1) LEFT OUTER join: The data of the left table is complete.
The data from the table (right table) is matched to the data in the main table (the left table):
1, match, return to result set
2, no match, null value returned to result set
SELECT S.sname,c.courseid,c.score
From Students as S
Left JOIN score as C
On c.studentid = S.scode
(2) Right outer join: Right table data is complete.
The data from the table (the left table) is matched to the data in the main table (right table):
1, match, return to result set
2, no match, null value returned to result set
SELECT Book number, book name, publisher name
From Book table
Rightjoin Publishing House Table
On the Books table. Publishing house number = Publisher table. Publishing house number

SQL Server database Multi-table federated query

Related Article

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.