简体   繁体   中英

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.

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

如果我理解正确的话,这应该可以解决问题。

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM