gpt4 book ai didi

mysql - 如何从 MySQL 中提取多列,其中一列是唯一值

转载 作者:行者123 更新时间:2023-11-29 11:17:25 24 4
gpt4 key购买 nike

我有一个金发时刻,我有一个时间戳和值列,我想从 PHP MySQL 表“mytable”中查询。不过,我只想获取一个值以及该值的相应时间戳。例如:

value,timestamp
23,2016-09-01 00:04:05
23,2016-09-01 00:04:05
23,2016-09-02 01:04:05 < --- extract this
24,2016-09-02 01:05:13
24,2016-09-03 01:04:24
27,2016-09-03 03:24:34
27,2016-09-04 04:24:42
27,2016-09-05 05:54:12
27,2016-09-06 00:04:05
27,2016-09-07 00:04:05 < --- extract this
28,2016-09-08 00:04:05 < --- extract this

我希望能够从上表中提取一个及其相应的时间戳

value,timestamp
23,2016-09-02 01:04:05
27,2016-09-07 00:04:05
28,2016-09-08 00:04:05

问:查询会是什么样子?

最佳答案

试试这个

SELECT
value,
MAX(TIMESTAMP)
FROM
yourTable
GROUP BY
value

关于mysql - 如何从 MySQL 中提取多列,其中一列是唯一值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39503446/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com