SELECT age, name FROM celeb WHERE age = 29 ORDER BY age;
SELECT age, name FROM celeb WHERE age != 29 ORDER BY age;
SELECT age, name FROM celeb WHERE age > 29 ORDER BY age;
SELECT age, name FROM celeb WHERE age < 29 ORDER BY age;
SELECT age, name FROM celeb WHERE age >= 29 ORDER BY age;
SELECT age, name FROM celeb WHERE age <= 29 ORDER BY age;
SELECT age, name FROM celeb WHERE age <> 29 ORDER BY age;
SELECT column1, column2.. FROM tablename WHERE condition1 AND condition2 ORDER BY column1;
SELECT column1, column2.. FROM tablename WHERE condition1 OR condition2 ORDER BY column1;
SELECT column1, column2.. FROM tablename WHERE NOT condition ORDER BY column1;
SELECT column1, column2.. FROM tablename WHERE column1 BETWEEN value1 AND value2 ORDER BY column1;
SELECT column1, column2.. FROM tablename WHERE column IN (value1, value2) ORDER BY column1;
SELECT column1, column2.. FROM tablename WHERE column LIKE pattern ORDER BY column1;
# ‘YG’로 시작하는 소속사 이름을 가진 데이터를 검색
SELECT * FROM celeb WHERE agency LIKE 'YG%';
# 직업명에 ‘가수’가 포함된 데이터를 검색
SELECT * FROM celeb WHERE agency LIKE '%가수%';
# 소속사 이름의 두번째 글자가 G인 데이터를 검색
SELECT * FROM celeb WHERE agency LIKE '_G%';
# 직업명이 ‘가' 로 시작하고 최소 2글자 이상인 데이터 검색
SELECT * FROM celeb WHERE job_title LIKE '가_%';
# 직업이 하나 이상인 연예인 중 영화배우 혹은 텔런트가 아닌 연예인 검색
SELECT * FROM celeb WHERE job_title LIKE '%,%' AND NOT (job_title LIKE '%영화배우%' OR job_title LIKE '%탤런트%');
Reference
1) 제로베이스 데이터스쿨 강의자료