The region column in the db table can be NULL, 0, or 1.

Which SQL demand can output all results with NULL and 1?

Request

 SELECT * FROM `db` WHERE `region` != '0' 

does not work according to the logic of NULL and 0 in this case, as one and the same, how to be?

  • NULL can only be checked explicitly. so where table=1 OR table IS NULL - Mike
  • Thanks, I was, but it does not work. And somehow strange, in general the request is not returned, even with an error - Oktu
  • TABLE keyword can't be used so easily - try renaming the field - Barmaley
  • Well, yes, I wrote it in a hurry and it is difficult to write reverse quotes in the comments. enclose the table in them as you had. and the error most likely your client displays which is not visible in a separate window - Mike
  • 2
    where IfNull ( region , 1)! = 0 - Zufir

1 answer 1

 SELECT * FROM `db` WHERE IfNull(`region`,1)!=0