Learn how to use SQL JOIN clause to combine the two tables and fetch record from those tables. Combine rows of two tables using the JOIN clause based on the same column on both the tables.
The common fields between the two tables can be used to perform the JOIN operation. You have to use the JOIN clause to access one or more table and fetch the data using the SQL SELECT statement.
There are five types of SQL JOIN given below in the list.
- Inner Join
- Left Outer Join
- Right Outer Join
- Full Outer Join
- Cross Join
You can learn about them in later tutorials given in the next pages with the examples and explanations. If you want to understand the JOIN clause with examples, keep reading this page tutorial.
How to Use SQL JOIN to Combine Two Tables
Suppose there are two tables, one for Purchaser and other for the Seller. Below are the tables you have to use to combine using the SQL JOIN clause.
Table Name: Purchaser
The above table contains the 4 columns with 4 rows of data.
Another table is for the Seller given below. It contains the Id field as the first column name. This column contains the id match with Purchase table Service_Id column.
To combine the above two tables, you have to use the common column called Service_Id between them. The example of the statement which you have to write to combine above two tables
SELECT Service_Id, Seller_Name, Purchaser_Name, Plot_No
FROM Purchaser p, Seller s
WHERE p.Service_Id = s.Id
The above output contains the columns which you have made combined using the JOIN clause. In the next chapters, you will learn details of all the types of JOIN.