开发者

Echoing oldest timestamp of a query

开发者 https://www.devze.com 2023-04-01 21:55 出处:网络
For this simple query, how do I echo out the datecommented timestamp (in minutes) of the oldest loginid?

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

精彩评论

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