TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

Oracle Outer Join

Oracle Outer Join example for beginners and professionals with examples on insert, select, update, delete, table, view, join, key, functions, procedures, indexes, cursor etc.

<< Back to ORACLE

Oracle OUTER JOIN

An outer join is similar to equijoin but it gets also the non-matched rows from the table. It is categorized in Left Outer Join, Right Outer Join and Full Outer Join by Oracle 9i ANSI/ISO 1999 standard.

Left Outer Join

Left Outer Join returns all rows from the left (first) table specified in the ON condition and only those rows from the right (second) table where the join condition is met.

Syntax

SELECT columns
FROM table1
LEFT [OUTER] JOIN table2
ON table1.column = table2.column; 

Image representation of left outer join

Oracle Left Outer Join

Example

In this example, we are performing left outer join on the already created tables ?suppliers? and ?order1?.

The following example would return all records from table ?suppliers? and only those records from table ?order1? where the join fields are equal.

Execute this query

SELECT suppliers.supplier_id, suppliers.supplier_name, order1.order_number
FROM suppliers
LEFT OUTER JOIN order1
ON suppliers.supplier_id = order1.supplier_id;

Output

Oracle Left Outer Join 2

Right Outer Join

The Right Outer Join returns all rows from the right-hand table specified in the ON condition and only those rows from the other table where the join condition is met.

Syntax

SELECT columns
FROM table1
RIGHT [OUTER] JOIN table2
ON table1.column = table2.column; 

Image representation of Right Outer Join

Oracle Right Outer Join

Example

In this example, we are performing right outer join on the already created tables ?suppliers? and ?order1?.

The following example would return all rows from the order1 table and only those rows from the suppliers table where the join condition is met.

Execute this query

SELECT order1.order_number, order1.city, suppliers.supplier_name
FROM suppliers
RIGHT OUTER JOIN order1
ON suppliers.supplier_id = order1.supplier_id;

Output

Oracle Right Outer Join 2

Full Outer Join

The Full Outer Join returns all rows from the left hand table and right hand table. It places NULL where the join condition is not met.

Syntax

SELECT columns
FROM table1
FULL [OUTER] JOIN table2
ON table1.column = table2.column; 

Image representation of Full Outer Join

Oracle Full Outer Join

Example

In this example, we are performing full outer join on the already created tables ?suppliers? and ?order1?.

The following example will return all rows from the ?suppliers? table and all rows from the ?order1? table and whenever the join condition is not met, it places the NULL value.

Execute this query

SELECT suppliers.supplier_id, suppliers.supplier_name, order1.order_number
FROM suppliers
FULL OUTER JOIN order1
ON suppliers.supplier_id = order1.supplier_id;

Output

Oracle Full Outer Join 2
Next TopicOracle EQUI JOIN




Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf