简体   繁体   English

从SQL获取结果,忽略一些数字

[英]Get result from sql with ignore some numbers

In MySQL table, i have a row for user groups. 在MySQL表中,我有一行用于用户组。 in this row i have user group numbers. 在这一行中,我有用户组号。 i'm trying to get result from all usergroups except 0 and 5. 我正在尝试从0和5以外的所有用户组获取结果。

I tried with this code: 我尝试使用以下代码:

$sql = $db->query("
SELECT 
author FROM dle_photo_post where ug<'5' and moder ='0'
");

Problem is i don't know how i can ignore 0 and 5. 问题是我不知道如何忽略0和5。

SELECT 
author FROM dle_photo_post where ug not in('5','0') and moder ='0'

Have you tried using : NOT ? 您是否尝试过使用:NOT?

Refer to http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html for further information. 有关更多信息,请参见http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html

SELECT author FROM dle_photo_post where ug!=5 and ug!=0

If ug is a single number then you should be able to do 如果ug是一个数字,那么您应该可以

SELECT
    author
FROM
    dle_photo_post
WHERE
    ug <> 5 AND ug <> 0

try, 尝试,

SELECT author 
FROM dle_photo_post 
where usergroups NOT IN (0, 5)
$sql = $db->query("
SELECT 
author FROM dle_photo_post where ug not in('0','5')
");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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