Home > database >  SELECT WHERE (`a` unequal '0') in sql
SELECT WHERE (`a` unequal '0') in sql

Time:05-23

I have:

`a` int DEFAULT '0'

From the thousands of records I have, I want to choose the ones that do not have a value of 0 or empty in a.

I tried something like this.

"SELECT * FROM TABLE WHERE (`a` unequal '0' or '') ;"

CodePudding user response:

try this

SELECT * FROM TABLE WHERE (`a` <>'0' or `a` = '' or `a` is null)

CodePudding user response:

Without giving away the answer:

Your WHERE clause is wrong. When you make multiple comparisons, you need to define which variable is being compared each time. It needs to be

SELECT *
FROM TABLE
WHERE a<>'whatever'
OR <>'whatever2'
  • Related