Rightjoin: a query type in the SQL language, that is, join query. It is called rightouterjoin and is a type of outer join.
Right join: the query type in SQL, that is, join query. It is called right outer join, which is a type of outer join.
Table A records the following:
| The code is as follows: |
|
AID aNum
1 a20050111
2 a20050112
3 a20050113
4 a20050114
5 a20050115 |
Table B records the following:
| The code is as follows: |
|
BID bName
1 2006032401
2 2006032402
3 2006032403
4 2006032404
8 2006032408 |
The SQL statement is as follows:
| The code is as follows: |
|
SELECT * FROM
Right joing B
ON a. aID = B. bID |
The result is as follows:
| The code is as follows: |
|
|
AID aNum bID bName
1 a20050111 1 2006032401
2 a20050112 2 2006032402
3 a20050113 3 2006032403
4 a20050114 4 2006032404
NULL 8 2006032408 |
(The number of affected rows is 5)
Result description:
After careful observation, we will find that the result of left join is exactly the opposite. this time, it is based on the right table (B) and is filled with NULL when Table A is insufficient.
Note the differences between on and where.
The ON statement is similar to the WHERE statement, but the ON statement is dedicated to join tables, the condition requirements and writing method after the ON statement are the same as those of the WHERE statement. you can basically use the ON statement as the WHERE statement.