Ccna final exam - java, php, javascript, ios, cshap all in one. This is a collaboratively edited question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.
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
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
Reading this original article on The Code Project will help you a lot: Visual Representation of SQL Joins.
ReplyDeleteAlso check this post: SQL SERVER – Better Performance – LEFT JOIN or NOT IN?.
Find original one at: Difference between JOIN and OUTER JOIN in MySQL.
What you really need to do is read up on relational algebra. Here's the Wiki article on joins, but read the wnole article.
ReplyDeleteINNER JOIN gets all records from one table that have some related entry in a second table
ReplyDeleteLEFT 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
The explanation by Jeff Attwood featuring Venn diagrams might do it for you.
ReplyDeleteA Visual Explanation of SQL Joins
W3 Schools has a great little write up on these with examples.
ReplyDeleteSQL Joins (go through all the chapters, it covers all the joins you asked about)