RE: [PHP] SQL statement - please help

From: Date: Thu, 24 Mar 2005 12:52:10 +0000
Subject: RE: [PHP] SQL statement - please help
Groups: php.general 
Request: Send a blank email to php-general+get-211454@lists.php.net to get a copy of this message
[snip] $sql = "Select tblchatglobal.cgid, tblchatglobal.cgdateposted, tblchatglobal.cgtimeposted, tblchatglobal.uid, tblchatglobal.cgmsg, tblusers.uid, tblusers.uusername from tblchatglobal, tblusers where (tblchatglobal.uid = tblusers.uid) and (DATE_SUB(CURDATE(),INTERVAL 1 HOUR) <= tblchatglobal.cgtimeposted) order by tblchatglobal.cgtimeposted desc"; [/snip] One of the MySQL lists will be really helpful to you. http://dev.mysql.com/doc/mysql/en/date-and-time-functions.html AND (DATE_SUB(CURDATE(),INTERVAL 1 HOUR)<= tblchatglobal.cgtimeposted) CURDATE is wrong here, as it only returns a date. NOW() returns a datetime. Try.... AND (DATE_SUB(NOW(),INTERVAL 1 HOUR)<= tblchatglobal.cgtimeposted)

« previous php.general (#211454) next »