bing
Flat 10% & upto 50% off + Free additional Courses. Hurry up!

JOINS

 

Join is used to combine rows of two or more tables by using common values.

Example:

Let us consider two tables first is Student details

Name Roll No. Marks
Akshay 1 57
Charu 2 68
Disha 3 52
Eva 4 68
Himanshu 5 75
Jitesh 6 88

 

Another table is Personal Detail.

Name City Phone No Email Id
Akshay Jaipur 9543846521 Akshay21@gmail.com
Disha Bombay 8532465892 Disha@gmail.com
Jitesh Banglore 9684365125 Jitesh1990@gmail.com

 

Let us join the two tables.

SELECT Name, City, Marks, Phone_no

FROM Student_detail, Personal_detail

WHERE Student_details.Name=Personal_detail.Name;

Name City Marks Phone No
Akshay Jaipur 57 9543846521
Disha Bombay 52 8532465892
Jitesh Banglore 88 9684365125

 

There are different types of Joins available in SQL:

  1. Inner Join
  2. Left Join
  3. Right Join
  4. Full Join

Inner Join:

It returns a value when there is a match in both the tables.

Left Join:

It returns all the values of the left table and matched the rows from the right table.

 

 

Syntax:

SELECT column_name

FROM table1

LEFT JOIN table2

ON table1.column_name=table2.column_name;

Example:

SELECT Student_details.Name, Address, Roll_no, Email_id

FROM Student_details

LEFT JOIN Personal_details

ON Student_details.Name= Personal_details.Name;

Name Roll No. Address Email Id
Akshay 1 Jaipur Akshay21@gmail.com
Charu 2 NULL NULL
Disha 3 Bombay Disha@gmail.com
Eva 4 NULL NULL
Himanshu 5 NULL NULL
Jitesh 6 Banglore Jitesh1990@gmail.com

 

Right Join:

It returns all the values of the right table and matched the rows from the left table.

Syntax:

SELECT column_name

FROM table1

RIGHT JOIN table2

ON table1.column_name=table2.column_name;

Example:

SELECT Personal_details.Name, Address, Roll_no, Email_id

FROM Student_details

RIGHT JOIN Personal_details

ON Student_details.Name= Personal_details.Name;

Name Address Roll NO. Email Id
Akshay Jaipur 1 Akshay21@gmail.com
Disha Bombay 3 Disha@gmail.com
Jitesh Banglore 6 Jitesh1990@gmail.com

FULL Join:

Full join returns all the rows from the left table and the right table.

Syntax:

SELECT column_name

FROM table1

FULL OUTER JOIN table2

ON table1.column_name=table2.column_name;

Example:

SELECT Student_details.Name, Roll_no, Address

FROM Student_details

FULL OUTER JOIN Personal_details

ON Student_details.Name= Personal_details.Name;

Name Roll No. Address
Akshay 1 Jaipur
Charu 2 NULL
Disha 3 Bombay
Eva 4 NULL
Himanshu 5 NULL
Jitesh 6 Banglore

 

"0 Responses on JOINS"

Training in Cities

Bangalore, Hyderabad, Chennai, Delhi, Kolkata, UK, London, Chicago, San Francisco, Dallas, Washington, New York, Orlando, Boston

100% Secure Payments. All major credit & debit cards accepted Or Pay by Paypal.

top

Sales Offer

  • To avail this offer, enroll before 09th December 2016.
  • This offer cannot be combined with any other offer.
  • This offer is valid on selected courses only.
  • Please use coupon codes mentioned below to avail the offer
offer-june

Sign Up or Login to view the Free JOINS.