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

后端 未结 5 550
囚心锁ツ
囚心锁ツ 2020-12-18 00:49

There\'s a big discussion going on at my office on the order of the joined columns in a sql join. I\'m finding it hard explaining it so I\'ll just present the two sql statem

5条回答
  •  半阙折子戏
    2020-12-18 01:17

    I have always used option 1 and that is also the way that orcale teach it on their SQL and PL/SQL course.

    On the subject of best practice though,

    One thing you have used that oracle also teach is the 1 or 2 letter table aliases.. Although this can seem like a great idea at the time and it makes writing the statement / procedure / function allot easier (at the time) it can be difficult to then come back and look at the same piece of code at a later date.

    e.g. We have many PL/SQL functions that are looking at / pulling data from tens of tables and while the aliases are fresh in your mind , great, but come back to the same code in a few years and it can get sticky.

    I'm not saying don't use table aliases but i always try and avoid the 1 or 2 letter ones that allot of places / people teach.

    (Not quite on the topic of joins only but on the topic of best practice)

提交回复
热议问题