LEFT JOIN/LEFT OUTER JOIN clause select all the records from left table(table1) and the matching records from the right table(table2).
Syntax of LEFT JOIN in SQL-
SELECT <column_name(s)>
FROM <table1>
LEFT JOIN<table2>
ON <table1.column_name=table2.column_name>
WHERE<condition>;
Example of LEFT JOIN in SQL-
SELECT Customers.CustomerName, Orders.OrderID
FROMCustomers
LEFT JOIN Orders
ONOrders.CustomerID = Customers.CustomerID;
LEFT JOIN returns all records from the left table (Customers), even if there are no matches in the right table (Orders). In the above example, SQL statement will select all customers and their orders.
Leave a Reply