Table T_user1,t_user2,t_user3, each with id,name two columns
There are two types of connections: inner and outer connections.
A . Internal Connection
Internal connections, the most common equivalent connection, for example:
SELECT *
from T_user1,t_user2
WHERE t_user1.id = t_user2.id
Results
id |
name |
id |
name |
1 |
10A |
1 |
10B |
B. External Connection
The outer connection is divided into left outer connection, right outer connection and full outer connection.
1. left outer join outer JOIN or Ieft Join
The left OUTER join is the addition of unmatched data from the primary table on the basis of the equivalent connection, for example:
SELECT *
from T_user1
Left OUTER JOIN T_user2
on t_user1.id = t_user2.id
Oracle supports an alternative notation
SELECT *
from T_user1, T_user2
WHERE t_user1.id=t_user2.id (+)
Results:
Id |
Name |
Id |
Name |
1 |
10A |
1 |
10B |
2 |
20A |
|
|
Three tables do left outer joins
SELECT *
from T_user1
Left OUTER JOIN T_user2
on T_user1.id=t_user2.id
Left OUTER JOIN T_user3
on T_user1.id=t_user3.id
Another form of Oracle support
SELECT *
from T_user1,t_user2,t_user3
WHERE t_user1.id=t_user2.id (+)
and T_user1.id=t_user3.id (+)
Results:
id |
name |
id |
name |
id |
name |
1 |
10A |
1 |
10B |
1 |
10C |
2 |
20A |
|
|
|
|
2. right outer connection outer JOIN
The right outer join is based on the equivalent connection and the mismatched data of the connected table is added.
SELECT *
from T_user1
Right OUTER JOIN T_user2
on T_user1.id=t_user2.id
Another way that Oracle supports
SELECT *
from T_user1,t_user2
WHERE t_user1.id (+) =t_user2.id
Results:
Id |
Name |
Id |
Name |
1 |
10A |
1 |
10B |
|
|
3 |
30B |
3. full out -of-the-outer JOIN or complete join
A full outer join is a combination of unmatched data from the left and right tables on the basis of an equivalent join.
SELECT *
from T_user1
Full OUTER JOIN T_user2
on T_user1.id=t_user2.id
The equivalent of the whole outer join, the same table first left connected, and then right connected
SELECT t_user1.*,t_user2.*
from T_user1
Left OUTER JOIN T_user2
on t_user1.id = t_user2.id
UNION
SELECT t_user1.*,t_user2.*
from T_user2
Left OUTER JOIN T_user1
on t_user1.id = t_user2.id
Results:
Id |
Name |
Id |
Name |
1 |
10A |
1 |
10B |
2 |
20A |
|
|
|
|
3 |
30B |
So that's a lot to sum up. Later encountered again to write.
Intra-and outer-connection differences in Oracle