开发者

Echoing oldest timestamp of a query

For this simple query, how do I echo out the datecommented timestamp (in minutes) of the oldest loginid?

$queryuidcount = "select loginid, datecomm开发者_开发知识库ented from comment where (HOUR(NOW()) -       HOUR(datecommented)) <= 1 and loginid = '$uid'"; 
$uidresult = mysql_query($queryuidcount);


You can ask MySQL to give you the rows in a particular order:

  SELECT loginid, datecommented 
    FROM comment 
   WHERE (HOUR(NOW()) - HOUR(datecommented)) <= 1 
     AND loginid = '$uid' 
ORDER BY datecommented ASC
   LIMIT 1 -- use this if you only want 1 row (ie: the oldest row)

MySQL Reference: Sorting Rows

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜