This SQL in mysql 4 is too aggressive and seems to ignore my 30 day date
range, if I remove the AND it finds the date range I want, putting it back
in does not.  I have tried various ways of wrapping ( and ) in the SELECT to
no avail.

I am trying to get all records where the subject is one of the 3 subjects
but also falls within 30 days old

SELECT id, name FROM listmail
WHERE date_time > DATE_SUB(NOW(), INTERVAL 30 DAY)
AND  subject = "semaphore" ||
subject = "Re: semaphore" ||
subject = "Re:semaphore"
ORDER BY id ASC LIMIT 60


For what its worth, this does what I want for me, but I am concerned this
will allow SQL injection in the subject as the emails come in.  running
mysqlescape (or whatever it is called) seems to make myslq cranky.
SELECT id, name FROM listmail WHERE date_time > DATE_SUB(NOW(), INTERVAL 30
DAY) AND  subject IN ('semaphore', 'Re: semaphore', 'Re:semaphore') ORDER BY
id ASC LIMIT 60

-- 
-------------------------------------------------------------
Scott Haneda                                Tel: 415.898.2602
http://www.newgeo.com                       Fax: 313.557.5052
[EMAIL PROTECTED]                            Novato, CA U.S.A.



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to