mysql 查询 字段是否为空

£神魔★判官ぃ 2021-09-07 06:01 483阅读 0赞

示例如下:

isnull()

  1. select * from users where email = 'xxxx' and isnull(deletedAt)

is null

  1. select * from users where email = 'xxxx' and deletedAt is null

is not null

  1. select * from users where email = 'xxxx' and deletedAt is not null

!isnull()

  1. select * from users where email = 'xxxx' and !isnull(deletedAt)
  2. select * from users where email = 'xxxx' and not isnull(deletedAt)

isfull

当查询条件为 null,用指定字符替代

  1. select name, isfull(gender,'未知') as gender from users where email = 'xxxx'

发表评论

表情:
评论列表 (有 0 条评论,483人围观)

还没有评论,来说两句吧...

相关阅读