Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LEFT JOIN and IS NULL effect

At http://dev.mysql.com/doc/refman/5.5/en/left-join-optimization.html one can read:

If you use LEFT JOIN to find rows that do not exist in some table and you have the following test: col_name IS NULL in the WHERE part, where col_name is a column that is declared as NOT NULL, MySQL stops searching for more rows (for a particular key combination) after it has found one row that matches the LEFT JOIN condition.

Can any body explain me what that mean in a human readable language? or in a newbie readable language ;)


1 Answers

Only rows that has no match on the right table will only be returned. This can be illustrated as:

enter image description here

As you can see, there are two tables being joined. The shaded part are the records which do not exists on Table B.

like image 149
John Woo Avatar answered Apr 03 '26 02:04

John Woo