Joins for you MySQL Queries in your Projects
Mysql Joins for your projects. I always forget the syntax of mysql joins so i go to this bookmark page to remind me. Hopefully this helps other people.
This is a collection of joins that you can use in your database projects. Bookmark this page and you can save some time in join syntax or just memorize it. Also i have left a link for a MySQL cheat sheet that i use all the time. I have this in my desk in front of my face. Print it Out it is useful.
Inner Join
SELECT user.name, course.name FROM `user` INNER JOIN `course` on user.course = course.id;
Left Join
SELECT user.name, course.name FROM `user` LEFT JOIN `course` on user.course = course.id;
Right Join
SELECT user.name, course.name FROM `user` RIGHT JOIN `course` on user.course = course.id;
Outer Join
SELECT user.name, course.name FROM `user` LEFT JOIN `course` on user.course = course.id UNION SELECT user.name, course.name FROM `user` RIGHT JOIN `course` on user.course = course.id;