Reply to SQL statement - please help

Your name:

Reply:


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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация