Left/right join 和inner join 区别

For example:
Suppose a table and data table are such that b.
ab &
ID Stock name ID 
. 1. 1 15 A
2 50 B 2
. 3 C  

SELECT * from the Join Inner A = B ON a.id b.id
this connection syntax within a query, it produces results that
two tables are matched the record appears in the results list.
According to the above table, the results appear to be such
a.id b.id Stock name
. 1. 1 15 A
2 50 B 2
----------------------- -----
SELECT * from a, B = WHERE a.id b.id
this syntax is written within another connection, which performs the same result inner join

------------- -------------------

SELECT * from a left / right the Join B = ON a.id b.id
the outer left or right outer connecting the outer connecting grammar
If the left outer joins, it will display all the records in a table,
.. select a *, b * from a left join b on a.id = b.id
result of this query is:
a.id b.id Stock name
. 1. 1 15 A
2 50 B 2
. 3 C null null 
- ------------------------------------------
If it is a right outer joins, it will display all records in the table b,
SELECT a *, b * from the Join a right b = ON a.id b.id..
the results of this query is:
a.id b.id Stock name
. 1. 1 a 15
2 b 250

Reproduced in: https: //my.oschina.net/secyaher/blog/274100

Guess you like

Origin blog.csdn.net/weixin_33750452/article/details/91966866