MySQL-仅查询最早日期的记录
我有一张有日期和其他数据的表格MySQL-仅查询最早日期的记录,mysql,sql,Mysql,Sql,我有一张有日期和其他数据的表格 id | date_col | more data ---------------------------- 1 | '2017-01-01' | 'xdfaev' 2 | '2017-01-01' | 'aevere' 3 | '2017-02-03' | 'eefeee' 4 | '2017-02-03' | 'rhrrrr' 5 | '2017-05-04' | 'tuqbfr' 我只想查询包含最早日期的记录: 1 | '2017-01-
id | date_col | more data
----------------------------
1 | '2017-01-01' | 'xdfaev'
2 | '2017-01-01' | 'aevere'
3 | '2017-02-03' | 'eefeee'
4 | '2017-02-03' | 'rhrrrr'
5 | '2017-05-04' | 'tuqbfr'
我只想查询包含最早日期的记录:
1 | '2017-01-01' | more data
2 | '2017-01-01' | more data
如果我不知道最早的日期,我该如何查询呢?-这是SQL代码,但对于mySQL应该类似/相同,语法可能略有不同
Select FiledList
From Table where date_col =
(select MIN(date_col)
From Table)
试试这个:
select * from table where date_col = (select min(date_col) from table);