What is SQL Inner Join
The inner join can be used to combine the column values of two tables based on the join conditions. The query created by using the inner join find all the rows match between the column of both the tables.
In the above image, there are two table in which there are some matching rows. These matching rows gives the ouput table after using the JOIN statement. The filled color in the above image showing the output rows of the two tables.
Why You Should Use Inner Join in SQL Query
To combine two or more table, you can use the JOIN statement. Find the common rows of two tables and get the output in the new table created after the JOIN statement.
The inner join is the frequently used join in SQL query to join two or more tables.
How to Use SQL Inner Join to Combine Tables
To use the SQL inner join statement, you can use two tables. The first table is the main table that you have to use in the FROM. The second table is the table that you want to join with the main table or first table and use after JOIN.
INNER JOIN table2
ON table1.column_name = table2.column_name;
The third thing to do is to add the two tables by equating with the matching column name after the ON statement. To understand how to use the Join statement, you have to read further and check the below-given example.
However, you can use multiple tables with the JOIN statement. To get better performance of the query, you should limit the number of tables.
Example to Combine Two Tables Using SQL Inner Join Statement
To create a join statement in SQL, you have to use the SELECT statement. The select statement to join table creates a table with one or more columns from the two tables that you have specified.
Below are the two tables contain the column with one column matching rows.
SQL Inner Join Example Using the Select Statement
Table 1: Purchaser
Table 2: Seller
|1001||Big Show||[email protected]|
Now, let’s combine the above two tables using the example given below.
SELECT Service_Id, Seller_Name, Purchaser_Name, Plot_No
FROM Purchaser p, Seller s
WHERE p.Service_Id = s.Id