Let's suppose that I have the following PHP code in one of my files.
$myselect = "select * FROM thread WHERE forumid<>5 ORDER BY lastpost DESC LIMIT 10";
How do I also exclude threads where they come from forumid 18 or 19?
$myselect = "select * FROM thread WHERE forumid<>5 OR forumid<>18 or forumid<>19 ORDER BY lastpost DESC LIMIT 10";
but it wouldn't work. Can someone tell me how do I do it the right way?
What error, or problem are you getting when you run that page.
To admin i've never seen the: <>
Thing before. What is it, if it means = then just use that.
You want to select all the records except thos records with a forumid of 5,18 and 19? Is that right? You need to use logical AND not OR. If I am correct that sql statement will be returning all the records. Right?
With logical OR only one of the conditions needs to be true for the result to evaluate to true. So if you construct a truth table you can see that all records will evaluate to true:
$myselect = "SELECT *
WHERE forumid <> 5
AND forumid <> 18
AND forumid <> 19
ORDER BY lastpost DESC
Hehe, I don't know if that looks like a table to you - it looks ok in my browser.
| <>5 | <> 18 | <> 19 | <>5 OR <> 18 OR <> 19
5 | F | T | T | T
18 | T | F | T | T
19 | T | T | F | T
Pete <> is another way of writing the != (not equal to) comparison operater in MySQL. It is also used in visual basic.
Ok thanks, that changes everything!
:) Thanks sid, I was wondering what that did as well.