[英]What is the difference between “column is not null” and “column !=''” and 'column<> ''' in mysql query ?
如果“emp”是 MySQL 數據庫中表的列之一,請告訴我,以下查詢之間的區別:
emp <> ''
和emp not null
我很困惑,請幫助我。
與''
的比較檢查字符串是否等於空字符串,並且始終可以執行。
僅當數據庫列可以為空時, IS NOT NULL
測試才有意義。 你會故意讓它為空,特別是能夠區分“我知道這個值,它恰好是一個空白”和“這個值在這里不適用,或者我不知道”。
您可能還想查看 MySql 文檔關於NULL
值的說法。
emp <> ''
不會匹配 null 的列。 對於 null 測試,您必須使用emp is not null
,因為 null 不匹配任何內容。
emp <> ''
測試值是否與空字符串不同,而emp is not null
測試您的值是否與 null 不同。 與 null 比較時,應始終使用is null
或is not null
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.