Reputation: 1058
In MySQL table, i have a row for user groups. in this row i have user group numbers. i'm trying to get result from all usergroups except 0 and 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.
Upvotes: 0
Views: 174
Reputation: 13785
$sql = $db->query("
SELECT
author FROM dle_photo_post where ug not in('0','5')
");
Upvotes: 1
Reputation: 263733
try,
SELECT author
FROM dle_photo_post
where usergroups NOT IN (0, 5)
Upvotes: 1
Reputation: 64526
If ug
is a single number then you should be able to do
SELECT
author
FROM
dle_photo_post
WHERE
ug <> 5 AND ug <> 0
Upvotes: 1
Reputation: 504
Have you tried using : NOT ?
Refer to http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html for further information.
Upvotes: 1
Reputation: 13506
SELECT
author FROM dle_photo_post where ug not in('5','0') and moder ='0'
Upvotes: 1