SUMMER TRAINING Free Tutorials  Go To Your University  Placement Preparation 
Project Based Best Summer Training Courses in Jaipur
Investing in yourself is easy. Udemy online courses now from INR 455
0 like 0 dislike
42 views
in Artificial Intelligence(AI) & Machine Learning by Goeduhub's Expert (3.1k points)

What is an alias command in SQL? How do I create an alias in SQL? How does SQL alias work? How to write comments in SQL? 

1 Answer

0 like 0 dislike
by Goeduhub's Expert (3.1k points)
edited by
 
Best answer

SQL Aliases (AS)

In SQL alias is used to improve the readability of queries. We use a SQL alias to give a temporary name to tables and columns. 

Sometimes column's name is not very descriptive and up to the point, In this case, we can give a temporary name to columns using an alias for our convenience.  

Note: Note that it requires double quotation marks or square brackets if the temporary name contains space. 

SELECT column_name AS alias_name (temporary name)
FROM table_name;

For Tables 

SELECT column_name
FROM table_name AS alias_name ; (temporary name)

SQL Self Join

As we already discussed the joints in SQL between tables. A self-join is the same as others but the difference is, the table is joined with itself.

Table b - Table b is same as a but alias name used here

SELECT a.column_name, b.column_name...
FROM table1 a

INNER JOIN table b ON a.matching_coulumn= b.matching_column 

SQL UNION 

SQL Comments 

Comments are used to describe the queries without disturbing the functionality of queries. 

Single Line Comment

--Selecting whole data of table
SELECT * FROM table_name;

Multiline comment  

/*Multiline comments are used

to describe queries in

more than one line*/
SELECT * FROM table_name;

Our Mentors(For AI-ML)


Sharda Godara Chaudhary

Mrs. Sharda Godara Chaudhary

An alumna of MNIT-Jaipur and ACCENTURE, Pune

NISHA (IIT BHU)

Ms. Nisha

An alumna of IIT-BHU

Related questions

 Goeduhub:

About Us | Contact Us || Terms & Conditions | Privacy Policy || Youtube Channel || Telegram Channel © goeduhub.com Social::   |  | 
...