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.

  1. Inner Join
  2. Left Outer Join
  3. Right Outer Join
  4. Full Outer Join
  5. 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

Purchaser_ID Purchaser_Name Plot_No Service_Id
1 Bill 26 10001
2 Nick 27 10002
3 Loony 28 10003
4 Monk 29 10004

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.

Table Name: Seller

Id Seller_Name Seller_Email
10001 Rock rock@gmail.com
10002 Sanky sanky@gmail.com
10003 Kurt kurt@gmail.com

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

Output

Service_Id Seller_Name Purchaser_Name Plot_No
10001 Rock Bill 26
10002 Sanky Nick 27
10003 Kurt Loony 28

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.

Reference

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.