SQL JOINS
SQL JOIN clause is used to combine and extract rows from two or more tables by joining common field. These joins are specified with FROM or WHERE clause mostly. Kindly note that INNER JOIN clause and JOIN clause both are same and you will get the same output.
There are different types of SQL JOINs as listed below.
- INNER JOIN
- Equi-Joins
- Natural Joins
- OUTER JOIN
- LEFT JOIN (also called LEFT OUTER JOIN)
- RIGHT JOIN (also called RIGHT OUTER JOIN)
- FULL JOIN (also called FULL OUTER JOIN)
- CROSS JOIN
Here we will consider one example for INNER JOIN condition where we will use two tables named as SalesDetails and ClientDetails.
Table Name: SalesDetails
Table Name: ClientDetails
From above two tables, we need columns OrderID and OrderDate from SalesDetails table and one column ClientName from ClientDetails table and sorted in ascending order by OrderDate column. So to get the output from two tables we will use INNER JOIN query as given below.
SELECT OrderID, ClientName, OrderDate FROM SalesDetails INNER JOIN ClientDetails ON SalesDetails.ClientID = ClientDetails.ClientID ORDER BY OrderDate
You can see the output by joining two tables in result pane where required data is sorted by OrderDate column.
Also Refer:
Reference: Manzoor Siddiqui [www.SQLServerLog.com]