Back

Explore Courses Blog Tutorials Interview Questions

Explore Tech Questions and Answers

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

0 votes
2 views
by (20.3k points)

You can set table aliases in SQL typing the identifier right after the table name.

SELECT * FROM table t1;

You can even use the keyword AS to indicate the alias.

SELECT * FROM table AS t1;

What's the difference between them if any?

I see old DBA people tend to write statements without AS, but most of the new tutorials use it.

Update: I know what's the purpose of table and column aliases. I'm curious, what's the reason for having a separate keyword for setting aliases while it works without it as well.

1 Answer

0 votes
by (119k points)
edited by

You can use either of the SQL queries and both serve the same purpose in this case. I recommend using AS operator and it is a good practice to use. AS operator is used to give another name to the table or column in the database. 

Suppose, if you want to reduce the discount of 100 from product_cost.

SELECT (product_cost -100) as Discount 

FROM product_table 

In case you wish to learn SQL from the industry experts then take up this SQL Certification course by Intellipaat

Related questions

0 votes
1 answer
asked Oct 19, 2020 in SQL by dev_sk2311 (45k points)
0 votes
4 answers
asked Mar 14, 2021 in SQL by dev_sk2311 (45k points)
0 votes
1 answer
0 votes
1 answer
asked Aug 16, 2020 in SQL by Sudhir_1997 (55.6k points)
0 votes
1 answer

Browse Categories

...