본문 바로가기

TOOL/MySQL

MySQL - is null( ), is not null( )

반응형
is null( )

 

 

 

null인 데이터만 사용하고 싶을때 쓰는 함수

 

 

select *
from series s
left join reviews r
	on s.id = r.series_id
where r.rating is null;

 

 

 

회원가입은 했지만, 사진은 한번도 올리지 않는 유저들의 데이터를 가져오기 (null인 데이터만 가져오기)

select u.username
from users u
left join photos p
on u.id = p.user_id
where p.image_url is null;

 

 

 

 

 

is not null

 

 

null이 아닌 데이터만 사용하고 싶을때 쓰는 함수

 

 

select *
from users u
left join photos p
	on u.id = p.user_id
where p.image_url is not null;

 

 

is null( ) , is not null( ) 함수를 이용하면

 

null인 데이터를 가진  or  null이 아닌 데이터를 가진

 

고객의 데이터를 활용해 데이터 분석을 할 수 있다.

 

 

 

 

 

반응형