Last Updated: February 25, 2016
·
510
· formidablefrank

MySQL Joins

Why do you have to use JOIN, OUTER/INNER JOIN, LEFT/RIGHT JOIN instead of NATURAL JOIN?

This NATURAL JOIN magical keyword greatly simplifies your work at joining tables.

Instead of doing

SELECT * FROM table1 JOIN table2 JOIN table3
WHERE table1.a = table2.a AND table2.b = table3.b;

You can do this:

SELECT * FROM table1 NATURAL JOIN table2 NATURAL JOIN table3

And all the data will be consolidated!

Take note that I use NATURAL JOINs only for tables with common unique or primary key columns :) And this method mostly serve my purposes.

If you want another method of joining other than what I described, use the general JOIN statements :)