Mysql——查詢字段是否為空


如何設置條件

  • 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'
    


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM