OR : 더하기, 합집합
남자가 아니거나 30세 이하인 유저
SELECT *
FROM `thelook_ecommerce.users`
WHERE gender <>'M';
AND : 곱하기, 교집합
일본에 살고 60세 이상인 유저
SELECT *
FROM `thelook_ecommerce.users`
WHERE gender <>'M'
OR AGE<=30;
NOT
일본이나 브라질에 살고 60세 이상인 유저
select *
from `thelook_ecommerce.users`
where (country = 'Japan' or country = 'Brasil')
and age >= 60
select *
from `thelook_ecommerce.users`
where age between 20 and 30;
# 같음
# where age >= 20 and age <= 30;
select *
from `thelook_ecommerce.users`
where created_at between '2021-01-01' and '2021-01-05';
# 같음
# where created_at >= '2021-01-01'
# and created_at <= '2021-01-05';
select * from `thelook_ecommerce.users`
where country in ('United States', 'Brasil', 'Korea', 'Japan');
# 같음
# where country = 'United States'
# or country = 'Brasil'
# or country = 'Korea'
# or country = 'Japan';
%
는 와일드카드user의 first_name안에 M
시작하는 레코드를 조회합니다.
select * from `thelook_ecommerce.users`
where first_name like 'M%';
user의 first_name에 M이 포함된 레코드를 조회
select * from `thelook_ecommerce.users`
where first_name like '%M%';
user의 first_name에 m으로 끝나는 레코드 조회
select * from `thelook_ecommerce.users`
where first_name like '%a';
_
의 개수에 따라 해당 글자 앞이나 뒤에 오는 글자 개수를 의미
# user의 first_name이 Da로 시작해서 3글자로 끝나는
select * from `thelook_ecommerce.users`
where first_name like 'Da___';