[Solved] SELECT * FROM USERS where userid = (null or ”) is this t sql query valid or not?


The comparison

 userid = (null OR '')  

is invalid. First, the very syntax is wrong:

 field = (value1 OR value2) 

should be put either as

(field = value1) OR (field = value2)  

or as

 field IN (value1, value2) 

Second, null is a special value, which stands for unknown, doesn’t matter, unapplicable etc. and that’s why null = null is equal not to True, but to null (does unknown equal to unknown? It’s unknown.) There are some exceptions when null = null is True (e.g. GroupBy). However, in order to be on the safe side do not put field = null or field in (..., null, ...), but field is null.
In your case

SELECT * 
  FROM users
 WHERE (userid is null) 
    OR (userid = '')

solved SELECT * FROM USERS where userid = (null or ”) is this t sql query valid or not?