Inner Joins


Prev Tutorial Next Tutorial

Inner Joins

Inner Join returns all rows when there is at least one match in both tables.

inner join

Inner joins use a comparison operator to match rows from two tables based on the values in common columns from each table. For example, retrieving all rows where the student identification number is the same in both the students and courses tables.

Inner Join uses some comparison operator like = or <>

Example of Join

Below we combined two table, table employee and table payment.

Employee table

Emp_idNameAge
101Amit Sukla24
102Rahul jain34
103Sultan Alam54
104Gaurav rawat26
105Hitesh Kumar35

Payment table

Payment_idDateSalary
10120-01-201420000
10223-03-201445000
10312-02-201450000
10428-07-201455000
10520-11-201440000

After apply join on these two table, result show like below;

Example

	
SELECT emp_id, name, age,salary   
   FROM Employee e, Payment p  
   WHERE e.Emp_id =p.Payment_id;  

In above syntax we select 4 columns, emp_id, name, age and salary from table Employee and table Payment. And retrieving all rows where the employee identification number is the same in both the Employee and Payment tables.

Payment_idNameAgeSalary
101Amit Sukla2420000
102Rahul jain3445000
103Sultan Alam5450000
104Gaurav rawat2655000
105Hitesh Kumar3540000

Prev Tutorial Next Tutorial

Advertisements




Facebook Likes

Advertisements