[英]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.