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;