Академический Документы
Профессиональный Документы
Культура Документы
1 SELECT
2 a.id id_a,
3 a.color color_a,
4 b.id id_b,
5 b.color color_b
6 FROM
7 palette_a a
8 INNER JOIN palette_b b ON a.color = b.color;
Here is the output:
<img class="alignnone size-full wp-image-2031"
src="https://www.oracletutorial.com/wp-
content/uploads/2019/02/Oracle-Join-inner-join-example.png"
alt="Oracle Join - inner join example" width="219" height="58" />
As can be seen clearly from the result, the inner join returns rows
from the left table that match with the rows from the right table.
The following Venn diagram illustrates an inner join when
combining two result sets:
<img class="alignnone size-full wp-image-2032"
src="https://www.oracletutorial.com/wp-
content/uploads/2019/02/Oracle-Joins-Inner-Join.png" alt="Oracle Joins
- Inner Join" width="379" height="288"
srcset="https://www.oracletutorial.com/wp-
content/uploads/2019/02/Oracle-Joins-Inner-Join.png 379w,
https://www.oracletutorial.com/wp-content/uploads/2019/02/Oracle-
Joins-Inner-Join-300x228.png 300w" sizes="(max-width: 379px) 100vw,
379px" />
Oracle left join
The following statement joins the left table with the right table
using a left join (or a left outer join):
1 SELECT
2 a.id id_a,
3 a.color color_a,
4 b.id id_b,
5 b.color color_b
6 FROM
7 palette_a a
8 LEFT JOIN palette_b b ON a.color = b.color;
The output is shown as follows:
<img class="alignnone size-full wp-image-2039"
src="https://www.oracletutorial.com/wp-
content/uploads/2019/02/Oracle-Join-left-join-example.png" alt="Oracle
Join - left join example" width="223" height="99" />
The left join returns all rows from the left table with the matching
rows if available from the right table. If there is no matching row
found from the right table, the left join will have null values for the
columns of the right table:
The following Venn diagram illustrates the left join:
<img class="alignnone size-full wp-image-2034"
src="https://www.oracletutorial.com/wp-
content/uploads/2019/02/Oracle-Joins-Left-Join.png" alt="Oracle Joins -
Left Join" width="378" height="290"
srcset="https://www.oracletutorial.com/wp-
content/uploads/2019/02/Oracle-Joins-Left-Join.png 378w,
https://www.oracletutorial.com/wp-content/uploads/2019/02/Oracle-
Joins-Left-Join-300x230.png 300w" sizes="(max-width: 378px) 100vw,
378px" />
Sometimes, you want to get only rows from the left table that do
not exist in the right table. To achieve this, you use the left join
and a WHERE clause to exclude the rows from the right table.
For example, the following statement shows colors that only
available in the palette_a but not palette_b:
1 SELECT
2 a.id id_a,
3 a.color color_a,
4 b.id id_b,
5 b.color color_b
6 FROM
7 palette_a a
8 LEFT JOIN palette_b b ON a.color = b.color
9 WHERE b.id IS NULL;
Here is the output:
<img class="alignnone size-full wp-image-2040"
src="https://www.oracletutorial.com/wp-
content/uploads/2019/02/Oracle-Join-left-join-with-a-WHERE-
clause.png" alt="Oracle Join - left join with a WHERE clause"
width="225" height="58" />
The following Venn diagram illustrates the left join with the
exclusion of rows from the right table:
<img class="alignnone size-full wp-image-2033"
src="https://www.oracletutorial.com/wp-
content/uploads/2019/02/Oracle-Joins-Left-Join-with-Where.png"
alt="Oracle Joins - Left Join with Where" width="382" height="318"
srcset="https://www.oracletutorial.com/wp-
content/uploads/2019/02/Oracle-Joins-Left-Join-with-Where.png 382w,
https://www.oracletutorial.com/wp-content/uploads/2019/02/Oracle-
Joins-Left-Join-with-Where-300x250.png 300w" sizes="(max-width:
1 SELECT
2 a.id id_a,
3 a.color color_a,
4 b.id id_b,
5 b.color color_b
6 FROM
7 palette_a a
8 RIGHT JOIN palette_b b ON a.color = b.color;
Here is the output:
<img class="alignnone size-full wp-image-2041"
src="https://www.oracletutorial.com/wp-
content/uploads/2019/02/Oracle-Join-right-join-example.png"
alt="Oracle Join - right join example" width="221" height="101" />
1 SELECT
2 a.id id_a,
3 a.color color_a,
4 b.id id_b,
5 b.color color_b
6 FROM
7 palette_a a
8 RIGHT JOIN palette_b b ON a.color = b.color
9 WHERE a.id IS NULL;
Here is the output:
<img class="alignnone size-full wp-image-2042"
src="https://www.oracletutorial.com/wp-
content/uploads/2019/02/Oracle-Join-right-join-with-a-WHERE-
clause.png" alt="Oracle Join - right join with a WHERE clause"
1 SELECT
2 a.id id_a,
3 a.color color_a,
4 b.id id_b,
5 b.color color_b
6 FROM
7 palette_a a
8 FULL OUTER JOIN palette_b b ON a.color = b.color;
The following picture illustrates the result set of the full outer join:
<img class="alignnone size-full wp-image-2192"
src="https://www.oracletutorial.com/wp-content/uploads/2019/06/oracle-
joins-full-outer-join-example.png" alt="oracle joins - full outer join
1 SELECT
2 a.id id_a,
3 a.color color_a,
4 b.id id_b,
5 b.color color_b
6 FROM
7 palette_a a
8 FULL JOIN palette_b b ON a.color = b.color
9 WHERE a.id IS NULL OR b.id IS NULL;
Here is the result:
<img class="alignnone size-full wp-image-2043"
src="https://www.oracletutorial.com/wp-
content/uploads/2019/02/Oracle-Join-full-outer-join-with-a-WHERE-
clause.png" alt="Oracle Join - full outer join with a WHERE clause"
width="228" height="98" />
The following Venn diagram illustrates the above operation:
<img class="alignnone size-full wp-image-2037"
src="https://www.oracletutorial.com/wp-
content/uploads/2019/02/Oracle-Joins-Full-Outer-Join-with-Where.png"
alt="Oracle Joins - Full Outer Join with Where" width="382"
height="304" srcset="https://www.oracletutorial.com/wp-
content/uploads/2019/02/Oracle-Joins-Full-Outer-Join-with-Where.png
382w, https://www.oracletutorial.com/wp-
content/uploads/2019/02/Oracle-Joins-Full-Outer-Join-with-Where-
300x239.png 300w" sizes="(max-width: 382px) 100vw, 382px" />
Previous Tutorial:
Oracle IS NULL
Next Tutorial:
Oracle INNER JOIN
GETTING STARTED
• What Is Oracle Database
• Install Oracle Database Server
• Download Oracle Sample Database
• Create Oracle Sample Database
• Connect To Oracle Database Server
ORACLE DATA MANIPULATION
• SELECT
• Oracle DUAL Table
• ORDER BY
• SELECT DISTINCT
• WHERE
• Table & Column Aliases
• AND
• OR
• FETCH
• BETWEEN
• IN
• LIKE
• IS NULL
• Joins
• INNER JOIN
• LEFT JOIN
• RIGHT JOIN
• FULL OUTER JOIN
• CROSS JOIN
• Self Join
• GROUP BY
• HAVING
• UNION
• INTERSECT
• MINUS
• GROUPING SETS
• CUBE
• ROLLUP
• PIVOT
• UNPIVOT
• INSERT
• INSERT INTO SELECT
• INSERT ALL
• UPDATE
• DELETE
• MERGE
• Subquery
• Correlated Subquery
• EXISTS
• NOT EXISTS
• ANY
• ALL
ORACLE DATA TYPES
• Oracle Data Types
• NUMBER
• FLOAT
• BINARY_FLOAT
• CHAR
• NCHAR
• VARCHAR2
• NVARCHAR2
• DATE
• INTERVAL
• TIMESTAMP
• TIMESTAMP WITH TIME ZONE
RECENT TUTORIALS
• PL/SQL VARRAY
• PL/SQL Nested Tables
• PL/SQL Associative Array
• Mutating Table Error in Oracle
• Oracle DROP TRIGGER
SITE LINKS
• About
• Contact
• Privacy Policy
• Terms of Use
Copyright © 2019 Oracle Tutorial. All Rights Reserved.