1 개요[ | ]
- SQL Aliases
- SQL 별칭
- SQL AS
- 컬럼명, 테이블명 등이 길거나 특수문자가 포함된 경우, 짧고 쉬운 이름으로 대체할 수 있음
2 예시 1: 컬럼명[ | ]
Console
Copy
mysql> SELECT COUNT(*) AS cnt FROM Customers;
+-----+
| cnt |
+-----+
| 3 |
+-----+
Console
Copy
mysql> SELECT CONCAT(first_name,' ',last_name) AS full_name FROM employee;
+------------+
| full_name |
+------------+
| John Smith |
| Jane Doe |
+------------+
3 예시 2: 테이블명[ | ]
Console
Copy
mysql> SELECT a.person, a.amount, b.amount
-> FROM sales1 a, sales2 b
-> WHERE a.person = b.person;
+--------+--------+--------+
| person | amount | amount |
+--------+--------+--------+
| Joe | 1000 | 2000 |
| Alex | 2000 | 2000 |
+--------+--------+--------+
Console
Copy
mysql> SELECT a.person, a.amount amount1, b.amount amount2
-> FROM sales1 a, sales2 b
-> WHERE a.person = b.person;
+--------+---------+---------+
| person | amount1 | amount2 |
+--------+---------+---------+
| Joe | 1000 | 2000 |
| Alex | 2000 | 2000 |
+--------+---------+---------+
4 같이 보기[ | ]
5 참고[ | ]
편집자 Jmnote Jmnote bot 175.223.14.70
로그인하시면 댓글을 쓸 수 있습니다.