SQL Reference

Quick Reference

The AS keyword is used to output a column or table with a temporary alias for the duration of the query. Nothing in the database itself is altered.

Column Alias

The following creates two aliases, one for the customer_id column and one for the customer_name column.

SELECT customer_id AS ID, customer_name AS [Customer Name]
FROM Customers;

Note

If an alias contains a space, like Customer name does in the above example, it must be wrapped in square brackets [ ].

Table Alias

The following creates an alias for the Customers table and the Orders table, as is used to shorten the SELECT statement.

SELECT c.customer_id, o.customer_order
FROM Customers AS c, Orders AS o;

SQL Notes:

  • Any work being done to modify the structure of a database or delete tables or the the database itself should only be done after making a recent backup

We’d like to acknowledge that we learned a great deal of our coding from W3Schools and TutorialsPoint, borrowing heavily from their teaching process and excellent code examples. We highly recommend both sites to deepen your experience, and further your coding journey. We’re just hitting the basics here at 1SMARTchicken.