explain the joins

Submitted 3 years, 2 months ago
Ticket #353
Views 291
Language/Framework SQL
Priority Low
Status Closed

What is difference between INNERJOIN, LEFT JOIN RIGHT JOIN AND FULL JOIN?  

 

Submitted on Feb 16, 21
add a comment

1 Answer

Verified

INNER JOIN is a type of join where it gets all records that are common between both tables based on the supplied ON clause.

Syntax for inner join:

SELECT * from table1 INNER JOIN table2 where table1id = table2id;

LEFT JOIN  is a type of join where it gets all records from the LEFT linked and the related record from the right table ,but if you have selected some columns from the RIGHT table, if there is no related records, these columns will contain NULL.

Synatx for Left join:

SELECT * from table1 LEFT JOIN table2 where table1id = table2id;

RIGHT JOIN  is a type of join where it  is like the above but gets all records in the RIGHT table.

Syntax for Right join:

SELECT * from table1 RIGHT JOIN table2 where table1id = table2id;

FULL JOIN  is a type of join where it  gets all records from both tables and puts NULL in the columns where related records do not exist in the opposite table.

Syntax for Full join:

SELECT * from table1 FULL JOIN table2 where table1id = table2id;

Submitted 3 years, 2 months ago


Latest Blogs