Home > Backend Development > PHP Tutorial > PHP获取查询数据中最早的时间和最晚时间如何写?这样不知对不对

PHP获取查询数据中最早的时间和最晚时间如何写?这样不知对不对

WBOY
Release: 2016-06-13 12:26:50
Original
1165 people have browsed it

PHP获取查询数据中最早的时间和最晚时间怎么写??这样不知对不对

PHP获取查询数据中最早的时间和最晚时间怎么写??这样不知对不对
如下貌似运行正常啊,但是感觉并不是这样的写法吧

<br />$EarlyTime=mysql_result(mysql_query("select min(Time) from user where General=1 and UserID='".$row['DatID']."'",$conn),0);<br />$LatestTime=mysql_result(mysql_query("select max(Time) from user where General=1 and UserID='".$row['DatID']."'",$conn),0);<br />
Copy after login


而且我感觉这样的执行效率太慢了。。。。索引了已经  还这样慢  受不鸟


请大神给个标准的获取数据库中最早时间和最后时间的方法吧

感激不尽!坐等高手!十分感谢!
------解决思路----------------------
在 Time、General、UserID 上都有索引吗?

两句应该合在一起写
list($EarlyTime, $LatestTime) = mysql_fetch_row(mysql_query("select min(Time), max(Time) from user where General=1 and UserID='".$row['DatID']."'"));

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template