Computer Science/Database

W3Schools SQL | #18 SQL ALIASES 기능

토마토. 2022. 10. 28. 12:35

SQL Aliases

SQL Aliases

테이블, 테이블 명의 임시 이름을 지정한다.
AS

Alias Column Syntax

SELECT column_name AS alis_name
FROM table_name;

Alias Table Syntax

SELECT column_name(s)
FROM table_name AS alis_name;

Alias for Columns Example

SELECT CustomerID AS ID, CustomerName AS Customer
FROM Customers;
SELECT CustomerName AS Customer, ContactName AS [Contact Person]
FROM Customers;
SELECT CustomerName, Address+', '+PostalCode+' ' + City+', '+ Country AS Address
FROM Customers;

Alias for Tables Example

SELECT o.OrderID, o.OrderDate, c.CustomerName
FROM Customers AS c, Orders AS o
WHERE c.CustomerName='Around the Horn' AND c.CustomerID=o.CustomerID;
SELECT Orders.OrderID, Orders.OrderDate, Customers.CustomerName
FROM Customers, Orders
WHERE Customers.CustomerName='Around the Horn' AND Customers.CustomerID=Orders.CustomerID;