|
Posted by Jacques on 03/24/05 10:50
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
[Back to original message]
|