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