Database inner join, outer join (left outer join, right outer join, full outer join) and cross join

SQL database connection: inner join , and outer join ( left outer join , right outer join , and full join )

This experiment is carried out in the MySQL database. The initial table of the database is as follows:



1. Inner join : The result only contains rows from the two tables that meet the join conditions. as follows:



2. Outer join : The result contains rows that meet the conditions and rows that do not meet the conditions (divided into left outer join, right outer join and full outer join)

1. Left outer join : all rows in the left table + matching rows in the right table, if a row in the left table does not have a matching row in the right table, the row in the right table displays NULL. as follows:



2. Right outer join : The opposite of left outer join. as follows:



3. Full outer join : Regardless of whether the match is matched or not, all are displayed. The left table displays NULL if the right table does not have it, and the right table displays NULL if the left table does not have it.

(MySQL database does not support full outer join, so a syntax is converted, the original way:

select * from student full join score on student.sno=score.sno;



3. Cross join : Returns the combination of all rows in the left table and all rows in the right table, also known as Cartesian product


This article is a reprinted article, the original link: https://blog.csdn.net/u012050154/article/details/52497395


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324773059&siteId=291194637