11智能在线
新记
mysql,查询日期是2012-1-1的数据,sql怎么写
表里有个datetime类型的字段
我要查询日期是2012-1-1的数据
sql语句里,where条件怎么写
举报该文章
相关建议 2012-11-14
使用date_format将表中datetime字段的值转换成“年月日”格式的字符串即可
语句这样写:
select * from 表名 where date_format(日期字段,'%Y-%m-%d') = ‘2012-1-1’;
记得采纳。
温馨提示:内容为网友见解,仅供参考
当前网址:
https://11.t2y.org/zz/sm4242v8s.html
其他看法
第1个回答 2012-11-14
列名=‘2012-1-1’ 如果你数据库里存的是时间戳列名=时间戳
第2个回答 2012-11-14
datetime='2012-1-1'
第3个回答 2012-11-14
select * from tb where day like '2012-1-1%' ;
相似回答
大家正在搜
相关问题
mysql 查询条件在当年一月一日到当前日期的记录 sql语...
在数据库中查询一段时间内的数据,SQL语句怎么写
在mysql中用时间作为条件进行查询,获取数据库中的数据,s...
mysql时间区间数据数量查询sql怎么写
mysql数据库时间字段是时间戳,怎样查询最近2015年1月...
mysql根据日期查询!!
SQL语句怎么查询在某日期之前的数据?
SQL数据库里有一个日期字段(格式2012-1-5 8:40...