Expired articles appear after expiration date

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I have a table, "article" that has a datetime field "article_expires".
In my SQL statement I have this:

SELECT id, title, body
FROM article
WHERE (article_expires IS NOT NULL OR article_expires = '' OR
article_expires LIKE '0000-00-00%' OR article_expires < now())
ORDER BY ranking DESC, record_entered DESC, upper(title) ASC,
upper(body) ASC

Here is info in the table for one row with an expiration date:

| id | title
        | article_expires     |
|  1 | This article should never appear               | 2006-06-12
14:55:36 |

Yet in my resultset this article appears even as of 3:04pm!  What am I
possibly doing wrong for this to happen and how can I fix this? The
goal is to only show unexpired articles AND/OR articles that have no
expiration date.


Re: Expired articles appear after expiration date

Quoted text here. Click to load it

There's a lot of redundancy here.  if article_expires matches
any of the last 3 OR clauses, then it's also not null, so
you might as well just say

WHERE article_expires IS NOT NULL

Quoted text here. Click to load it

What is it you're really trying to do?

                    Gordon L. Burditt

Site Timeline