"AS" function vs not using "AS" function to assign alias

Can someone please help explain to me if there is a difference between using the “AS” function vs not using “AS” function to assign alias? and when should you use it vs when NOT to use it?

In the course subject “Inner Join” Mosh didnt use the “AS” function to assign “O” as an alias to Order and “C” as an alias to Customer.

Im new, so i dont know.

When making a table or column alias, the AS keyword (which is not a function, by the way) is optional. Personally I don’t often use AS before my aliases, but if I’m working with someone else’s query and they’re using it, I will follow with that pattern. If you’re new to SQL then it might be good to get in the habit of always using AS in your queries. It might also depend on your preferred query structure (formatting). I often will add each column on its own line, so the readability factor is (arguably) less important than if your columns are all listed on a single line, in which case I could see how it would make things more readable, especially since most SQL editors will colorize keywords.

1 Like