SQL JOIN

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_IDPurchaser_NamePlot_NoService_Id
1Bill2610001
2Nick2710002
3Loony2810003
4Monk2910004

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

IdSeller_NameSeller_Email
10001Rock[email protected]
10002Sanky[email protected]
10003Kurt[email protected]

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_IdSeller_NamePurchaser_NamePlot_No
10001RockBill26
10002SankyNick27
10003KurtLoony28

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 comment

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.