programplug Logo



SQL Joins

JOIN IN SQL


JOIN states to combine something. In SQL, it means that 'combination of one or two tables'


In SQL following joins are available:
  • Inner Join
  • Full outer Join
  • Left Join
  • Outer Join
  1. Inner Join: It returns all rows in a table when there is at least one comparesion in both the tables.
  2. Full Join: It return all rows in a table when there is a match in one of the tables available.
  3. Left Join: It return all rows from the left table and then compare rows from the right table.
  4. Right Join: It return all rows from the right table and then compared rows from the left table.
Example:
E_ID E_NAME E_SALARY
201 Robert 37000
202 Michael 73500
203 Foster 45000
204 Luke 80000
Week off:
Shift_id E_AGE E_Day
201 41 Friday
202 37 Saturday
203 33 Sunday
204 35 Thursday

After Joining the table we get:

Example:
SELECT emp_id,e_name,e_salary   
FROM Employee e, week off o  
WHERE e.Emp_id =o.shift_id;
Result:
Shift_id E_NAME E_AGE E_SALARY
201 Robert 41 37000
202 Michael 37 73500
203 Foster 33 45000
204 Luke 35 80000