1. 程式人生 > 資料庫 >MYSQL 判斷為空和空字串

MYSQL 判斷為空和空字串

MYSQL 中,進行空值的判斷:

判斷某個欄位是否為空

isnull 判斷是否為空:
只有當欄位為null時,isnull()返回1,空串和有資料都為0
select * from user where ISNULL(name)=1;
is not null
select * from user where name is not null;

判斷某個欄位是否為空串

select goods_id,item_code from goods_info where LENGTH(trim(item_code))>0