Expired articles appear after expiration date

Expired articles appear after expiration date

am 12.06.2006 21:09:41 von phillip.s.powell

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

[Code]
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
[/Code]

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

[Quote]
----+------------------------------------------------------- -------------------+---------------------+
| id | title
| article_expires |
+----+------------------------------------------------------ --------------------+---------------------+
| 1 | This article should never appear | 2006-06-12
14:55:36 |
[/Quote]

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.

Thanx
Phil

Re: Expired articles appear after expiration date

am 12.06.2006 22:16:43 von gordonb.fzrvv

>I have a table, "article" that has a datetime field "article_expires".
>In my SQL statement I have this:
>
>[Code]
>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())

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

>ORDER BY ranking DESC, record_entered DESC, upper(title) ASC,
>upper(body) ASC
>[/Code]

What is it you're really trying to do?

Gordon L. Burditt