Do you use the OUTER keyword when writing left/right JOINs in SQL?

后端 未结 8 2250
臣服心动
臣服心动 2021-02-13 22:25

I often see people who write SQL like this:

SELECT * from TableA LEFT OUTER JOIN TableB ON (ID1=I2)

I myself write simply:

SELE         


        
相关标签:
8条回答
  • 2021-02-13 23:10

    OUTER really is superfluous, as you write, since all OUTER joins are either LEFT or RIGHT, and reciprocally all LEFT or RIGHT joins are OUTER. So syntactically it's mostly noise, as you put it. It is optional even in ISO SQL. As for why people use it, I suppose some feel the need the insist on the join being OUTER, even if the left-or-right keyword already says so. For that matter, INNER also is superfluous!

    0 讨论(0)
  • 2021-02-13 23:16

    One thing that several months on Stackoverflow has shown me is how much SQL is written and / or maintained by people with no previous exposure to SQL or relational databases at all.

    For that reason, I think that the more explicit you can be the better off the next programmer is going to be when looking at your code.

    0 讨论(0)
提交回复
热议问题