Inner Joins
Advertisements
Inner Joins
Inner Join returns all rows when there is at least one match in both tables.
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_id | Name | Age |
---|---|---|
101 | Amit Sukla | 24 |
102 | Rahul jain | 34 |
103 | Sultan Alam | 54 |
104 | Gaurav rawat | 26 |
105 | Hitesh Kumar | 35 |
Payment table
Payment_id | Date | Salary |
---|---|---|
101 | 20-01-2014 | 20000 |
102 | 23-03-2014 | 45000 |
103 | 12-02-2014 | 50000 |
104 | 28-07-2014 | 55000 |
105 | 20-11-2014 | 40000 |
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_id | Name | Age | Salary |
---|---|---|---|
101 | Amit Sukla | 24 | 20000 |
102 | Rahul jain | 34 | 45000 |
103 | Sultan Alam | 54 | 50000 |
104 | Gaurav rawat | 26 | 55000 |
105 | Hitesh Kumar | 35 | 40000 |
Google Advertisment