개발일지/DataBase
Alias
E-room
2022. 7. 2. 11:44
728x90
쿼리가 점점 길어지고 복잡해지게 되면 혼동이 올 수 있다.
그럴때 사용하는 것이 Alias라는 별칭을 지어주는 기능이다.
ex) 테이블명 뒤에 붙이는 경우 orders o
select * from orders o
where o.course_title = '앱개발 종합반'
ex) 출력될 필드에 별칭을 붙이는 겨우
count(*) as cnt => Alias(as)를 붙이게 되면 별칭(cnt)로 출력이 되며 호출할 때도 별칭으로 호출할 수 있음.
select payment_method, count(*) as cnt from orders o
where o.course_title = '앱개발 종합반'
group by payment_method
728x90