DELETE mySQL query

------=_NextPart_000_0044_01CA1E07.CA8F1720
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Is there a way to do the math in a DELETE statement (All 1 step; See my =
"sample" below pseudo code below). I am trying to delete the record if =
it is more than 3 hours old and the value of "approved" is still 0.

DELETE FROM `guest_book` WHERE `guest_book`.`date_submitted` + 3 hours =
=3D< '$current_time' AND `guest_book`.`approved` =3D '0' LIMIT 1
------=_NextPart_000_0044_01CA1E07.CA8F1720--
Ron Piggott [ So, 16 August 2009 06:23 ] [ ID #2012373 ]

Re: DELETE mySQL query

On Aug 16, 2009, at 12:23 AM, "Ron Piggott"
<ron.php [at] actsministries.org> wrote:

> Is there a way to do the math in a DELETE statement (All 1 step; See
> my "sample" below pseudo code below). I am trying to delete the
> record if it is more than 3 hours old and the value of "approved" is
> still 0.
>
> DELETE FROM `guest_book` WHERE `guest_book`.`date_submitted` + 3
> hours =< '$current_time' AND `guest_book`.`approved` = '0' LIMIT 1

Check out the timediff function in mysql's SQL

http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functio ns.html#function_timediff

Bastien

Sent from my iPod

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Phpster [ So, 16 August 2009 14:47 ] [ ID #2012374 ]
PHP » gmane.comp.php.database » DELETE mySQL query

Vorheriges Thema: GROUP BY
Nächstes Thema: DELETE mySQL query