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

后端 未结 8 2273
臣服心动
臣服心动 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 22:56

    YES

    It just make things clearer in my opinion - the clearer and more obvious you state your intent, the better (especially for someone else trying to read and understand your code later on).

    But that's just my opinion - it's not technically needed, so you can use it - or leave it.

    0 讨论(0)
  • 2021-02-13 22:56

    I use the OUTER keyword myself. I agree it is merely a matter of taste but omitting it strikes me as being a little sloppy but not as bad a omitting the INNER keyword (sloppy) or writing SQL keywords in lower case (very sloppy).

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

    I think there is no such thing as portable SQL in the year 2009 anyway... At some point, you need to write DBMS-specific statements (like retrieving top N rows).

    I personally find the JOIN syntax redundant and instead I comma-separate table names.

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

    It is simply a matter of taste, I guess that people use it because they find that it leads to more readable code. For example, I prefer to use the also optional AS keyword since SELECT ... FROM table AS t looks more readable than SELECT ... FROM table t for me.

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

    No. I use

    • JOIN
    • LEFT JOIN
    • RIGHT JOIN
    • FULL OUTER JOIN
    • CROSS JOIN

    There is no ambiguity for me.

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

    I'm using 'inner join', 'left join', 'right join', and 'full outer join'. 'join' without 'inner' makes it somewhat ambigious to me; 'left' and 'right' are self-descriptive and 'full' is such kind of a beast that it deserves special syntax :)

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