Adrian
Adrian

Reputation: 2291

How to select all values from a column except a value in Mysql?

For example I have the query:

$legend= mysql_num_rows(mysql_query("SELECT * FROM  users WHERE rank = 'Legend' AND status='Alive' AND userlevel <> '2'"));

I need to know how you do the excluding sign, because it seams that <> is not correct.

Upvotes: 1

Views: 3276

Answers (3)

BaBL86
BaBL86

Reputation: 2622

SELECT * 
FROM  users 
WHERE rank = 'Legend' 
AND status='Alive' 
AND userlevel != '2'

Upvotes: 1

Sonya Krishna
Sonya Krishna

Reputation: 269

Try like this

$legend= mysql_num_rows(mysql_query("SELECT * FROM  users WHERE rank = 'Legend' AND status='Alive' AND userlevel !='2'"));

This will query results having rank as Legend and status as Alive excluding userlevel with 2

Upvotes: 1

Realit&#228;tsverlust
Realit&#228;tsverlust

Reputation: 3953

$legend= mysql_num_rows(mysql_query("SELECT * FROM  users WHERE rank = 'Legend' AND status='Alive' AND userlevel != '2'"));

This should do the trick if i understood you correctly.

Upvotes: 1

Related Questions