Monday 5 September 2016

SQL JOINS with Examples

SQL JOINS with Examples


SQL JOIN :- The SQL Joins clause is used to combine records from two or more tables in a database. A JOIN is a means for combining fields from two tables by using values common to each.

INNER JOIN:- An SQL INNER JOIN returns all rows from multiple tables where the join condition is met.

NOTE :- IN Example Using Table find in below link page.


Example:- 

SELECT Emp1.ID,Emp1.Name,User1.ID,User1.City
FROM Emp1
INNER JOIN User1
ON Emp1.ID=User1.ID;



LEFT JOIN :- The SQL LEFT JOIN returns all rows from the left table, even if there are no matches in the right table.

EXAMPLE :- 

SELECT Emp1.ID,Emp1.Name,Emp1.Company,User1.ID,User1.Name,User1.City
FROM Emp1
LEFT JOIN User1
ON Emp1.ID=User1.ID;



RIGHT JOIN:- The SQL RIGHT JOIN returns all rows from the right table, even if there are no matches in the left table. 

EXAMPLE :- 

SELECT Emp1.ID,Emp1.Name,Emp1.Company,User1.ID,User1.Name,User1.City
FROM Emp1
RIGHT JOIN User1
ON Emp1.ID=User1.ID;




2 comments:

Factorial of a Number

Recently Viewed