Well you might need to parenthesize the expression, but note that
simple integer math done on a DATE or DATETIME, the units are days.
you probably want
... where first_seen < (NOW() - 5);
michael dykman
On Wed, Nov 4, 2009 at 2:28 PM, Stefan Onken <support@stripped> wrote:
> Hello,
>
> I am new to using triggers in mysql. I am using mysql 5.1.37 and would like
> to setup a trigger like:
>
> CREATE TRIGGER greylist AFTER INSERT on greylist
> delete from greylist where first_seen < NOW()-60*60*24*5;
> END;
>
> When typing this into mysql I am getting an error. Where is my mistake?
>
>
> mysql> show fields from greylist;
> +---------------+---------------+------+-----+---------+
> | Field | Type | Null |
> Key | Default |
> +---------------+---------------+------+-----+---------+
> | id | int(11) | NO
> | PRI | NULL |
> | SenderIP | varchar(15) | NO | MUL | NULL
> |
> | SenderAddress | varchar(1024) | NO | MUL | NULL |
> | first_seen | int(11) | NO |
> | NULL |
> +---------------+---------------+------+-----+---------+
> 4 rows in set (0,00 sec)
>
> I would like to archive that after every insert in the greylist table I am
> purging the oldest xx records.
>
> Stefan
>
>
>
> www.stonki.de : My, myself and I
> www.kbarcode.net : barcode solution for KDE
> www.krename.net : renamer for KDE
> www.proftpd.de : a FTP server...
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe: http://lists.mysql.com/mysql?unsub=1
>
>
--
- michael dykman
- mdykman@stripped
"May you live every day of your life."
Jonathan Swift