Understanding SQL Outer Join in Database Queries

Slide Note
Embed
Share

SQL Outer Join is a powerful feature that combines data from multiple tables even when there are no exact matches. It includes Left Outer Join and Right Outer Join, allowing you to retrieve all records from one table and matching records from another. The LEFT JOIN keyword fetches all records from the left table and corresponding matches from the right table, whereas the RIGHT JOIN keyword retrieves all records from the right table and their matches from the left table.


Uploaded on Sep 15, 2024 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

E N D

Presentation Transcript


  1. Lesson 25 SQL OUTER JOIN Trainer: Bach Ngoc Toan TEDU Website: http://tedu.com.vn

  2. SQL OUTER JOIN In the SQL outer JOIN all the content of the both tables are integrated together either they are matched or not. Outer join of two types: 1.Left outer join (also known as left join): this join returns all the rows from left table combine with the matching rows of the right table. If you get no matching in the right table it returns NULL values. 2.Right outer join (also known as right join): this join returns all the rows from right table are combined with the matching rows of left table .If you get no column matching in the left table .it returns null value.

  3. SQL LEFT JOIN KEYWORD The LEFT JOIN keyword returns all records from the left table (table1), and the matched records from the right table (table2). The result is NULL from the right side, if there is no match. SELECT column_name(s) FROM table1 LEFT JOIN table2 ON table1.column_name = table2.colu mn_name; In some databases LEFT JOIN is called LEFT OUTER JOIN.

  4. SQL RIGHT JOIN KEYWORD The RIGHT JOIN keyword returns all records from the right table (table2), and the matched records from the left table (table1). The result is NULL from the left side, when there is no match. SELECT column_name(s) FROM table1 RIGHT JOIN table2 ON table1.column_name = table2.column _name; In some databases RIGHT JOIN is called RIGHT OUTER JOIN.

Related