ajsie
ajsie

Reputation: 79786

sql operator equivalent to !=

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

My mistake.

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

Answers (7)

OMG Ponies
OMG Ponies

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

philfreo
philfreo

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

Niklas Rosencrantz
Niklas Rosencrantz

Reputation: 26637

NOT IN is one flavor and here's a tsql negate example

Upvotes: -1

David Thomas
David Thomas

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

Ken
Ken

Reputation: 2944

In SQL, I believe inequality is

<>

though many implementations also allow

!=

Upvotes: 3

Mitch Wheat
Mitch Wheat

Reputation: 300719

SELECT * 
FROM table 
WHERE columnname <> value

Upvotes: 10

Dave
Dave

Reputation: 5173

WHERE NOT columnname = value

Upvotes: 0

Related Questions