MySQL_Workbench

MySQL에서, 값이 null 인지 확인 할 때는, is null 사용

K2ODING 2021. 12. 9. 17:42
728x90
  • 데이터가 없는 title 컬럼에 'MISSING'이라고 채우려고 한다.
select students.first_name,
case
	when papers.title is null then 'MISSING'
	else papers.title
end as title
from students
left join papers
	on students.id = papers.student_id;

출력

※  is null 부분

when papers.title = null then 'MISSING'

= 을 사용하면 안됨 is 를 사용 해야함