0% found this document useful (0 votes)
28 views3 pages

Right Join Syntax: SELECT Column - Name(s) FROM Table1 LEFT JOIN Table2 ON Table1.column - Name Table2.column - Name

The document describes different types of JOINs in SQL: INNER JOIN only returns rows that match between both tables, LEFT JOIN returns all rows from the left table even if no matches in the right table, RIGHT JOIN returns all rows from the right table even if no matches in the left table, and FULL OUTER JOIN returns all rows from both tables including those with no matches. Examples of SQL queries are provided for each type of JOIN.

Uploaded by

Tanvi Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views3 pages

Right Join Syntax: SELECT Column - Name(s) FROM Table1 LEFT JOIN Table2 ON Table1.column - Name Table2.column - Name

The document describes different types of JOINs in SQL: INNER JOIN only returns rows that match between both tables, LEFT JOIN returns all rows from the left table even if no matches in the right table, RIGHT JOIN returns all rows from the right table even if no matches in the left table, and FULL OUTER JOIN returns all rows from both tables including those with no matches. Examples of SQL queries are provided for each type of JOIN.

Uploaded by

Tanvi Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Note: The INNER JOIN keyword selects all rows

from both tables as long as there is a match


between the columns. If there are rows in the
"Customers" table that do not have matches in
"Orders", these customers will NOT be listed.
Left join
SELECT column_name(s)
FROM table1
LEFT JOIN table2
ON table1.column_name=table2.column_name;

he LEFT JOIN keyword returns all the rows from


the left table (Customers), even if there are no
matches in the right table (Orders).

RIGHT JOIN Syntax


SELECT column_name(s)
FROM table1
RIGHT JOIN table2
ON table1.column_name=table2.column_name;

The RIGHT JOIN keyword returns all the rows


from the right table (Employees), even if there
are no matches in the left table (Orders).

FULL OUTER JOIN Syntax

SELECT column_name(s)
FROM table1
FULL OUTER JOIN table2
ON table1.column_name=table2.column_name;

The FULL OUTER JOIN keyword returns all the


rows from the left table (Customers), and all the
rows from the right table (Orders). If there are
rows in "Customers" that do not have matches in
"Orders", or if there are rows in "Orders" that do
not have matches in "Customers", those rows will
be listed as well.

SELECT Customers.CustomerName,
Orders.OrderID
FROM Customers
LEFT JOIN Orders
ON Customers.CustomerID=Orders.CustomerID
ORDER BY Customers.CustomerName;

SELECT Orders.OrderID, Employees.FirstName


FROM Orders
RIGHT JOIN Employees
ON Orders.EmployeeID=Employees.EmployeeID
ORDER BY Orders.OrderID;

SELECT Customers.CustomerName, Orders.OrderID


FROM Customers
FULL OUTER JOIN Orders
ON Customers.CustomerID=Orders.CustomerID
ORDER BY Customers.CustomerName;

You might also like