mysql判斷字段是否為空的方法:可以利用isNULL()函數來進行判斷,具體代碼為【select * from users where email = ‘xxxx’ and isnull(deletedAt)】。
MySQL是一個關系型數據庫管理系統,由瑞典MySQL AB 公司開發,目前屬于?oracle?旗下產品。MySQL 是最流行的關系型數據庫管理系統之一,在 WEB 應用方面,MySQL是最好的?RDBMS?(Relational database Management System,關系數據庫管理系統) 應用軟件。
(推薦教程:mysql視頻教程)
當我們需要知道mysql中的某個字段是否為空?怎么實現呢?
這里提供了5種方法進行查詢:
isnull()
select?*?from?users?where?email?=?'xxxx'?and?isnull(deletedAt)
is null
select?*?from?users?where?email?=?'xxxx'?and?deletedAt?is?null
is not null
select?*?from?users?where?email?=?'xxxx'?and?deletedAt?is?not?null
!isnull()
select?*?from?users?where?email?=?'xxxx'?and?!isnull(deletedAt)? select?*?from?users?where?email?=?'xxxx'?and?not?isnull(deletedAt)
isfull
當查詢條件為 null,用指定字符替代
select?name,??isfull(gender,'未知')?as?gender??from?users?where?email?=?'xxxx'
? 版權聲明
文章版權歸作者所有,未經允許請勿轉載。
THE END
喜歡就支持一下吧
相關推薦