Monday, April 23, 2012

What"s the difference between (INNER JOIN,LEFT JOIN,RIGHT JOIN,FULL JOIN) in Mysql


I want to know What's the difference between INNER JOIN,LEFT JOIN,RIGHT JOIN,FULL JOIN in Mysql



i'm confused in that


Source: Tips4all

5 comments:

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



    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.

    ReplyDelete
  2. What you really need to do is read up on relational algebra. Here's the Wiki article on joins, but read the wnole article.

    ReplyDelete
  3. INNER JOIN gets all records from one table that have some related entry in a second table

    LEFT JOIN gets all records from the LEFT linked table but if you have selected some columns from the RIGHT table, if there is no related records, these columns will contain NULL

    RIGHT JOIN is like the above but gets all records in the RIGHT table

    FULL JOIN gets all records from both tables and puts NULL in the columns where related records do not exist in the opposite table

    ReplyDelete
  4. The explanation by Jeff Attwood featuring Venn diagrams might do it for you.

    A Visual Explanation of SQL Joins

    ReplyDelete
  5. W3 Schools has a great little write up on these with examples.

    SQL Joins (go through all the chapters, it covers all the joins you asked about)

    ReplyDelete