Welcome to the OzoneAsylum FaqWiki
Frequently Asked Questions
Server Side Coding

How do I make a 'not equal to' statement in MySQL? Pages that link to <a href="https://ozoneasylum.com/backlink?for=5402" title="Pages that link to How do I make a &amp;#039;not equal to&amp;#039; statement in MySQL?" rel="nofollow" >How do I make a &#039;not equal to&#039; statement in MySQL?\

There are a number of ways to do this.


WHERE 'something' <> 'something_else'


WHERE 'something' != 'something_else'

As they are identical.

or you can specify a number of values you don't want to be return from your column/field (my_tablein this example) - a more efficient way of doing things if you have a lot of values:

WHERE my_table NOT IN ('something', 'something_else');

Relevant links:

select problem with "not equal" syntax

Comparison Operators

Mysql Pocket Reference

Using the SQL SELECT Statement with MySQL

Using MySQL with Perl

Relevant notes:

At the time of writing this FAQ was ranked number 1 at Google for the terms sql, statement, using, not, equal, to and 7 for sql, not, equal .


(Added by: Emperor on Fri 08-Nov-2002)

(Edited by: Emperor on Thu 01-May-2003)

« BackwardsOnwards »

Show Forum Drop Down Menu