Is my JOIN syntax not valid? And have I understood JOIN correctly? I've been reading up a bit regarding JOINs. And i just noticed that I've been writing the syntax a little bit different. Although I don't think there's any problem with it, I would like to hear your oppinions.

This is how I see just about every tutorials writes the syntax:

SELECT a.&lt;columns&gt;
    b.&lt;columns&gt; 
FROM table_a a 
    INNER JOIN table_b b ON a.pk = b.fk_table_a_pk


And this is how I've been doing it:

SELECT a.&lt;columns&gt;
    b.&lt;columns&gt; 
FROM table_a a 
    JOIN table_b b ON b.fk_table_a_pk = a.pk


As you can see; I've switched around the part where the comparison takes place.
Instead of a.pk = b.fk_table_a_pk, I do 
b.fk_table_a_pk = a.pk. I don't know why, but I would guess it's because it made more sense - in my head - to continue "working" on the joined table (JOIN table_b b ON b.fk_table_a_pk =)

I've always gotten the expected result, so I've never thought about it. But is this wrong? Or is there situations, that I'm not aware of yet, where this could fail and return an unexpected result?

An additional question regarding LEFT and RIGHT joins.
Is it correct to say that the joined table (table_b) is the RIGHT table? - and that table_a is the LEFT table - in this case?
And if I continue the code like this:

....
FROM table_a a 
    JOIN table_b b ON b.fk_table_a_pk = a.pk
    JOIN table_c c ON c.fk_table_a_pk = a.pk


they're both RIGHT tables relative to table_a?  And if I continue like this:

    ....
    JOIN table_c c ON c.fk_table_a_pk = a.pk
        JOIN table_d ON d.fk_table_c_pk = c.pk


now table_c is still RIGHT relative to table_a, but is now also LEFT relative to table_d - and of course then table_d is RIGHT relative to table_c - in this case?
The = sign represents the symmetric equal operator. It does not matter in which order the to sides are mentioned, they are still equal.

As for the LEFT and RIGHT JOIN, the table order is important here. As you stated correctly, it is:

...FROM LeftTable LEFT JOIN RightTable ON...

...FROM LeftTable RIGHT JOIN RightTable ON...


The LEFT JOIN returns all rows of the LeftTable regardless of a match, the RIGHT JOIN returns all rows of the RightTable regardless of a match.

For more information on how JOINs work, check out my article series here: http://sqlity.net/en/1146/a-join-a-day-introduction/

It is written for Microsoft SQL Server but most of the concepts are RDBMS independent.