Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/241.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php MySQL:从最高月份获取所有行的查询_Php_Mysql - Fatal编程技术网

Php MySQL:从最高月份获取所有行的查询

Php MySQL:从最高月份获取所有行的查询,php,mysql,Php,Mysql,我有一个名为“accounts”的表,它有两个字段“month”和“amount”。我喜欢在头版显示最高月份记录 eg: month amount 10/2013 -> 12 12/2013 -> 20 12/2013 -> 21 11/2013 -> 10 如何过滤最高月份的所有数据,我使用时间戳格式存储日期 可以工作。如上表所示,您需要21金额行?@MahmoodRehman确实需要21,20金额行最远月份=上个月?但如何在显示最高月份数据后停止查询用户可以从表

我有一个名为“accounts”的表,它有两个字段“month”和“amount”。我喜欢在头版显示最高月份记录

eg:

month amount

10/2013 -> 12
12/2013 -> 20
12/2013 -> 21
11/2013 -> 10

如何过滤最高月份的所有数据,我使用时间戳格式存储日期


可以工作。

如上表所示,您需要
21
金额行?@MahmoodRehman确实需要21,20金额行最远月份=上个月?但如何在显示最高月份数据后停止查询用户可以从表中选择最大(月);
SELECT * FROM accounts WHERE month = (SELECT MAX(month) FROM accounts)