본문 바로가기
DataBase/MySQL

[MySQL] SQL에서의 Null값을 알아보자! 🧐

by coding-choonsik 2023. 3. 16.
728x90
반응형
SMALL

1. Null과 ' ' 공백 데이터

select null;

데이터없음

select '';

.공백데이터 출력

 

. Null인 데이터 조회하기

 

 

1-1. null의 연산

select 100 + null;

결과: null, 연산 불가능

select 100 + '';

결과: 100, 문자열 연산됨

 


2. Null 데이터 조회하기

select * from member;

 

✅ address1이 null값인 회원의 userid, username, hp 필드 조회

select userid, username, hp from member where address1 is null;

✅ address1이 null값이 아닌 회원의  userid, username, hp 필드 조회

select userid, username, hp from member where address1 is not null;

 

 

728x90
반응형
LIST