Merged into mysql5
I saw people write the following query
SELECT column_name(s)
FROM table_name1
LEFT JOIN table_name2
ON table_name1.column_name=table_name2.column_name
written like this:
SELECT column_name(s)
FROM table_name1
LEFT JOIN table_name2
ON table_name2.column_name =table_name1.column_name
does it really matter?
source to share
Not under normal circumstances, no. Imagine there might be a fairly complex query, much more complex than your examples, where the join optimizer is so overwhelmed that it might make a difference, but even if it is possible, you have to work quite hard.
You can write both of them as USING (column_name)
by the way. :)
I would also recommend that you familiarize yourself with the DIY analysis of such problems EXPLAIN
.
source to share
This is probably a matter of personal taste; I happen to write unions like your second example, but I can't say that I am 100% in agreement with that.
Also, in The Bad Old Days, when query optimizers weren't as smart as they are now, you might find that reordering the operands in a union expression or clause WHERE
can make a big difference; that is, the optimizer will use the index if the operands are ordered in one direction, but not in the opposite direction.
I think I have Oracle 7 flash memory. Got to lie down ...
source to share