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
精彩评论