Best practices for the order of joined columns in a sql join?

The best practice here is to choose one and stick with it within the team. Personally, I prefer the FROM a JOIN b ON b.col = a.col because it seems cleaner to me.


SQL was designed to be readable as usual English text. In a usual text, when we want to specify any mentioned object, we say something like "An object. This object is like that object, this object is related to that object, and this object has those properties." We do not say "That object is like this object, to that object related this object and those properties have this object".

So, when we adding records of TableB to query from TableA, we need to specify what must have a record from TableB to satisfy current record from TableA. So we must say, we need that records from TableB, which have an id, equal to TableA.ID. FROM TableA a JOIN TableB b ON b.col = a.col. We must write exactly in this order, to provide easy reading and understanding of this relation.

And I'm very very sad, that almost all SQL documentation does not provide any kind of reasoning to go one or another direction in this question, but have a lot of examples of wrong writing equation arguments in order of presenting of tables in a query.

Tags:

Sql