Database/MySQL

MySQL Null Condition

BUST 2019. 1. 23. 22:53

MySQL Null Condition


# Wrong Condition
select * from table where  column = null
select * from table where  column != null

# Correct Condition
select * from table where column is null
select * from table where column is not null


# null이거나, 특정값이 아닌 경우
## Wrong, VALUE가 아닌경우의 검색 조건, 하지만 null일때의 데이터값을 가지고 올수가 없다.
select * from table where column != 'VALUE'  

## Correct
select * from table where (column != 'VALUE or column is null)


참고 - https://dev.mysql.com/doc/refman/8.0/en/working-with-null.html