Reputation: 79786
I want to select all the fields where a certain column is not a value I specify.
I tried this but it didn't work.
SELECT *
FROM table
WHERE columnname != value
It was another error so I thought it was wrong with !=
operator cause it was the first time I use it. Sorry guys!
Upvotes: 1
Views: 273
Reputation: 332661
You need to post the query you are using, because !=
works fine for me in MySQL 4.1
As others mentioned, <>
is equivalent. The !=
is ANSI standard (99 I believe).
Upvotes: 1
Reputation: 43834
For MySQL:
!=
or <>
are correct.
http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html
You should consider NULL
columns also. You can do WHERE columnname IS NOT NULL
also.
Upvotes: 5
Reputation: 26637
NOT IN is one flavor and here's a tsql negate example
Upvotes: -1
Reputation: 253396
Either <>
or !=
From: MySQL Manual (version 5.0)
<>, !=
Not equal:
mysql> SELECT '.01' <> '0.01'; -> 1 mysql> SELECT .01 <> '0.01'; -> 0 mysql> SELECT 'zapp' <> 'zappp'; -> 1
Upvotes: 2
Reputation: 2944
In SQL, I believe inequality is
<>
though many implementations also allow
!=
Upvotes: 3