繁体   English   中英

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

[英]Get result from sql with ignore some numbers

在MySQL表中,我有一行用于用户组。 在这一行中,我有用户组号。 我正在尝试从0和5以外的所有用户组获取结果。

我尝试使用以下代码:

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

问题是我不知道如何忽略0和5。

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

您是否尝试过使用:NOT?

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

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

如果ug是一个数字,那么您应该可以

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

尝试,

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