조건을 모두 만족하는 경우 TRUE
SELECT column1, column2, ...
FROM tablename
WHERE condition1 AND condition2 AND condition3, ...;
하나의 조건이라도 만족하는 경우 TRUE
SELECT column1, column2, ...
FROM tablename
WHERE condition1 OR condition2 OR condition3, ...;
조건을 만족하지 않는 경우 TRUE
SELECT column1, column2, ...
FROM tablename
WHERE NOT condition;
조건값이 범위 사이에 있으면 TRUE
SELECT column1, column2, ...
FROM tablename
WHERE column1 BETWEEN value1 AND value2;
목록 안에 조건이 존재하는 경우 TRUE
SELECT column1, column2, ...
FROM tablename
WHERE column IN (value1, value2, ...);
조건값이 패턴에 맞으면 TRUE
SELECT column1, column2, ...
FROM tablename
WHERE column LIKE pettern;
zerobase database
celeb table
USE zerobase;
desc celeb;
select * from celeb;
select name, age from celeb where age=29 order by age;
select name, age from celeb where age!=29 order by age;
select name, age from celeb where age>29 order by age;
select name, age from celeb where age<29 order by age;
select name, age from celeb where age>=29 order by age;
select name, age from celeb where age<=29 order by age;
select name, age from celeb where age<>29 order by age;
select name, age from celeb where age<=30 order by age;
select name, age, sex, job_title, agency
from celeb
where name='아이유';
select name, job_title, agency
from celeb
where agency!='YG엔터테이먼트'
order by agency;
select name, sex, job_title
-> from celeb
-> where sex='M'
-> order by age DESC, agency ASC;
select sex, agency, name, age
from celeb
where age < 50
order by sex ASC, agency DESC, name ASC;
AND: 조건을 모두 만족하는 경우 TRUE
SELECT * FROM celeb WHERE age=29 AND sex='F';
select * from celeb where sex='M' and age > 40 order by name;
select * from celeb where sex='M' and agency='YG엔터테이먼트' order by agency;
select * from celeb where age >= 30 and sex='M' order by age;
OR: 조건이 하나만 해당하면 TRUE
select * from celeb where (age<29 AND sex='F') OR (age>30 and sex='M');
select * from celeb
where (age<29 AND sex='F') OR (age>30 and sex='M')
order by age, sex;
select * from celeb
where (id%2 = 1 and sex='M') or (id%2 = 0 and agency='YG엔터테이먼트')
order by age;
NOT: 조건을 만족하지 않는 경우 TRUE
select *
from celeb
where not agency='YG엔터테이먼트' and age<=40
order by name;
select *
from celeb
where (birthday > 19891231 and not sex='F') or (birthday<19800101 and not agency='안테나');
select *
from celeb
where not agency='YG엔터테이먼트' AND age<=40
order by name;
select *
from celeb
where (not job_title='가수' and sex='F') or (not age<40 and (id%2)=1);
BETWEEN: 조건값이 범위 사이에 있으면 TRUE
select *
from celeb
where age BETWEEN 20 AND 40;
-> between 사용하지 않는 경우
select *
from celeb
where age>= 20 AND age<=40;
select *
from celeb
where ((NOT birthday BETWEEN 19800101 AND 19951231) AND sex='F') or (agency='YG엔터테이먼트' AND NOT age BETWEEN 20 AND 45);
select *
from celeb
where ((id between 1 and 5) and sex='F') OR
(id%2=1 and sex='M' and age between 20 and 30);
IN: 목록 안에 조건값이 존재하는 경우 TRUE
select *
from celeb
where age in (28, 48);
select *
from celeb
where (not agency in ('나무엑터스', '안테나', '울림엔터테이먼트')) and
(sex='F' or age >= 45);
LIKE: 조건값이 패턴에 맞으면 TRUE
select * from celeb where agency like 'YG엔터테이먼트';
select * from celeb where agency='YG엔터테이먼트';
%: 어떤 글자가 와도 상관없다.
select * from celeb where agency like 'YG%';
select * from celeb where agency like '%엔터테이먼트';
select * from celeb where JOB_TITLE like '%가수%';
'_': 한글자
'%': 어떤 글자가 와도 상관없다.
select * from celeb where agency like '_G%';
select * from celeb where JOB_TITLE like '가_%';
select * from celeb where JOB_TITLE like '%가수%' AND JOB_TITLE like '%연기자%';
select * from celeb
where (JOB_TITLE like '%,%') and
NOT (JOB_TITLE like '%영화배우%' or JOB_TITLE like '%연기자%');
select * from celeb
where age between 30 and 50 and
not job_title like '%개그맨%';
select * from celeb
where name in ('아이유', '이미주', '유재석', '송강') and
agency like '나무%';
select * from celeb
where name in ('아이유', '이미주', '송강', '이수현') and
((job_title like '가수') or (NOT job_title like '%가수%' and job_title like '%연기자%'));
이번주는 EDA 과제로 가득찬 한 주가 아닌가 싶다.
EDA 테스트 2개 EDA 과제 1개
물론 EDA가 익숙한 분들에게는 아주 간단한 문제들이겠지만 EDA 초보인 나에게는 과제 하나하나가 너무 어렵다구요ㅠㅠ 이렇게 한 주에 잔뜩 주시면 정신을 못차려요,,,^^
심지어 자소서까지 함께,,, 하하하하하 그래도 해결해나가면 기분 좋음
"이 글은 제로베이스 데이터 취업 스쿨 강의를 듣고 작성한 내용으로 제로베이스 데이터 취업 스쿨 강의 자료 일부를 발췌한 내용이 포함되어 있습니다."