RE: SQL statement - please help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[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)

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux