02 Mar, 2007
LEFT JOIN and RIGHT JOIN in mysql
Use LEFT JOIN when you want to return all rows from left table regardless of whether they have any associated rows on right table.
Use RIGHT JOIN when you want to return all rows from right table regardless of whether they have any associated rows on left table.
SELECT users.`firstname`, pets.`nickname` FROM `users` LEFT JOIN `pets` ON users.`id` = pets.`user`";
The above query will return all rows in users table regardless of whether they have any pets associated with them or not.
Technorati Tags: mysql, sql, join, left join, right join
Love what you've just read? Subscribe to our newsletter to receive tips, resources and special offers related to web development & design.
Hello! Welcome to Web development blog! My name is Ei Sabai and on this blog, I write about web development, mobile app development, latest web technologies and the likes. Read more 

