Gadgets 4 Students Online Courses
Free Tutorials  Go to Your University  Placement Preparation 
0 like 0 dislike
243 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? 

Where can I do online courses From Word's Top Instructors?

UDEMY::  Attend All Udemy Courses in Just INR 450[Coupon]
Coursera:: Join For FREE

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;

3.3k questions

7.1k answers

395 comments

4.5k users

Related questions

 Important Lists:

Important Lists, Exams & Cutoffs Exams after Graduation PSUs

 Goeduhub:

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

 

Free Online Directory
...