回应查询的最旧时间戳

时间:2011-08-31 01:36:57

标签: php mysql

对于这个简单的查询,如何回显最早的datecommented的{​​{1}}时间戳(以分钟为单位)?

loginid

1 个答案:

答案 0 :(得分:1)

您可以要求MySQL按特定顺序为您提供行:

  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