Inner Join

The SQLite Inner join is the most common type of join. It is used to combine all rows from multiple tables where the join condition is satisfied.

The SQlite Inner join is the default type of join.

Syntax:

SELECT ... FROM table1 [INNER] JOIN table2 ON conditional_expression ...   

or

SELECT ... FROM table1 JOIN table2 USING ( column1 ,... ) ...   

or

SELECT ... FROM table1 NATURAL JOIN table2...  

Image representation:

Sqlite Inner join 1

We have two tables “STUDENT” and “DEPARTMENT”.

Sqlite Inner join 2

The “STUDENT” table is having the following data:

Sqlite Inner join 3

The “DEPARTMENT” table is having the following data:

Sqlite Inner join 4

Let’s take the above two tables “STUDENT” and “DEPARTMENT” and make an inner join according to the below conditions:

Example:

SELECT EMP_ID, NAME, DEPT FROM STUDENT INNER JOIN DEPARTMENT  

 ON STUDENT.ID = DEPARTMENT.EMP_ID; 

    Output:

    Sqlite Inner join 5

    Comments

    Leave a Reply

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