Concat = 여러 문자열을 하나로 합치거나 연결하는 함수임.
기본 구조
SELECT CONCAT ('string1', 'string2', ...);
select concat('이름: ', ' ' , name) from celeb;
alias = 칼럼이나 테이블 이름에 별칭 생성
기본 구조
SELECT column as alias
FROM tablename;
SELECT col1, col2, ...
FROM tablename as alias;
01)
name을 이름으로, agency는 소속사로 별칭 만들기
select name as '이름', agency as '소속사' from celeb;
02)
name 과 job_title을 합쳐서 profile이라는 별칭을 만들어서 검색
✍️ concat과 alias 사용!
select concat (name, ' : ', job_title') as profile from celeb;
distinct = 검색한 결과의 중복 제거
기본구조
SELECT DISTINCT col1, col2,...
FROM tablename;
✍️ distinct 뒤의 col1, col2의 집합에 대한 중복을 제거!
01)
연예인 소속사 종류 검색 but 중복 제외
select distinct agency from celeb;
limit = 검색 결과를 정렬된 순으로 주어진 숫자만큼만 조회
기본구조
SELECT col1, col2, ...
FROM tablename
WHERE condition
LIMIT number;
01)
나이가 가장 적은 연예인 4명 검색
select *
from celeb
order by age
limit 4;