USE zerobase;
SELECT * FROM celeb;
SELECT CONCAT ('string1', 'string2', ...)
SELECT CONCAT ('concat', ' ', 'test')
SELECT CONCAT ('이름:', name) FROM celeb;
SELECT column as alias FROM tablename;
SELECT column1, column2, ... FROM tablename as alias;
ALIAS 예제 - 1
SELECT name as '이름' FROM celeb;
ALIAS 예제 - 2
SELECT name as '이름', agency as '소속사' FROM celeb;
ALIAS 예제 - 3
SELECT CONCAT(name, ' : ', job_title) as profile FROM celeb;
ALIAS 예제 - 4
SELECT s.season, s.episode, c.name, c.job_title FROM celeb AS c, snl_show AS s WHERE c.name = s.host;
ALIAS 예제 - 5
SELECT CONCAT(s.season, '-', s.episode, '(', s.broadcast_date, ')') AS '방송정보', CONCAT(c.name, '(', c.job_title, ')') AS '출연자정보' FROM celeb AS c, snl_show AS s WHERE c.name = s.host;
SELECT CONCAT(s.season, '-', s.episode, '(', s.broadcast_date, ')') AS '방송정보', CONCAT(c.name, '(', c.job_title, ')') AS '출연자정보' FROM celeb c, snl_show s WHERE c.name = s.host;
SELECT DISTINCT column1, column2, ... FROM tablename;
SELECT agency FROM celeb;
SELECT DISTINCT agency FROM celeb;
SELECT sex, job_title FROM celeb WHERE job_title LIKE '%가수%';
SELECT DISTINCT sex, job_title FROM celeb WHERE job_title LIKE '%가수%';
SELECT column1, column2, ... FROM tablename WHERE condition LIMIT number;
SELECT * FROM celeb LIMIT 3;
LIMIT 예제 - 2
LIMIT 예제 - 2 - 1
SELECT * FROM celeb ORDER BY age;
LIMIT 예제 - 2 - 2
SELECT * FROM celeb ORDER BY age LIMIT 4;
위 글은 제로베이스 데이터 취업 스쿨의 강의자료를 참고하여 작성되었습니다.