Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between INNER JOIN, LEFT JOIN, RIGHT JOIN and FULL JOIN? [duplicate]

What's the difference between INNER JOIN, LEFT JOIN, RIGHT JOIN and FULL JOIN in MySQL?

like image 362
Lion King Avatar asked Apr 18 '11 17:04

Lion King


People also ask

What is the difference between inner join and full join?

What is the difference between INNER JOIN and FULL JOIN. Inner join returns only the matching rows between both the tables, non-matching rows are eliminated. Full Join or Full Outer Join returns all rows from both the tables (left & right tables), including non-matching rows from both the tables.

What is difference between inner join and left outer join?

An inner join using either of the equivalent queries gives the intersection of the two tables, i.e. the two rows they have in common. A left outer join will give all rows in A, plus any common rows in B. A right outer join will give all rows in B, plus any common rows in A.

Which type of join is fastest?

If you dont include the items of the left joined table, in the select statement, the left join will be faster than the same query with inner join. If you do include the left joined table in the select statement, the inner join with the same query was equal or faster than the left join.


1 Answers

Reading this original article on The Code Project will help you a lot: Visual Representation of SQL Joins.

alt text

Also check this post: SQL SERVER – Better Performance – LEFT JOIN or NOT IN?.

Find original one at: Difference between JOIN and OUTER JOIN in MySQL.

like image 85
Pranay Rana Avatar answered Oct 07 '22 02:10

Pranay Rana