SQL statement - please help

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

 



Dear all

Please, I realy need your help.  I am trying to extract only those records 
that were entered during the past hour from my MySQL database.  The 
following SQL statement extracts all the records. As soon as I change the 
INTERVAL  to 1 HOUR I see all the records in my database. When I change 
CURDATE() to CURTIME() no records are extracted from the database. The 
cgtimeposted field is a time data type.

Please advise me as to how I can formulate my SQL statement so that only 
those records entered within the past hour displays on my page.

Here is my current SQL statement - this statement displays all the records:

$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";

Jacques 

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