Golang Tutorials - Learn Go Programming with Easy Step-by-Step Guides

Explore comprehensive Golang tutorials for beginners and advanced programmers. Learn Go programming with easy-to-follow, step-by-step guides, examples, and practical tips to master Go language quickly.

As in SQL

As in SQL

? AS in SQL – The Alias Keyword

The AS keyword in SQL is used to rename a column or table temporarily for readability or convenience. This is known as an alias.


? Syntax

? Alias for Columns:

SELECT column_name AS alias_nameFROM table_name;

? Alias for Tables:

SELECT t.column_nameFROM table_name AS t;

? AS is optional — you can also write aliases without it.


? Example Table: employees

idfirst_namelast_namesalary
1AliceSmith50000
2BobJones60000

? Examples

? 1. Column Alias

SELECT first_name AS fname, last_name AS lnameFROM employees;

? Output columns: fname, lname

? 2. Concatenate Columns with Alias

SELECT first_name || ' ' || last_name AS full_nameFROM employees;

In MySQL use: CONCAT(first_name, ' ', last_name)

? 3. Math Operation with Alias

SELECT salary * 12 AS annual_salaryFROM employees;

? 4. Table Alias

SELECT e.first_name, e.salaryFROM employees AS eWHERE e.salary > 50000;

? Makes queries easier to read, especially with joins.


? 5. Alias in JOINs

SELECT e.first_name, d.name AS departmentFROM employees AS eJOIN departments AS d ON e.department_id = d.id;

? Key Points

  • Aliases don’t change actual table/column names.

  • They only exist for the duration of the query.

  • Use aliases to:

    • Shorten long names

    • Improve readability

    • Format outputs nicely


Let me know if you'd like examples with nested queries or aliasing in views or reports!

Disclaimer for AI-Generated Content:
The content provided in these tutorials is generated using artificial intelligence and is intended for educational purposes only.
html
docker
php
kubernetes
golang
mysql
postgresql
mariaDB
sql