MySQL计数日期(MySQL count date)

编程入门 行业动态 更新时间:2024-10-27 18:24:26
MySQL计数日期(MySQL count date)

为什么会这样呢?

在特定日期之前,此查询不应该检索记录数吗?

SELECT count(*) FROM `posts` WHERE date < 2013-01-01

我在db上有几条与查询匹配的记录,但是,计数为0

我究竟做错了什么??

Why is this happening

Shouldn't this query retrieve the number of records until a specifc date?

SELECT count(*) FROM `posts` WHERE date < 2013-01-01

I have several records on the db that match the query, however, the count comes 0

What am I doing wrong??

最满意答案

您需要使用DATE将字符串定义为DATE

SELECT count(*) FROM posts WHERE date < DATE('2013-01-01')

You need to define your string as a date using DATE

SELECT count(*) FROM posts WHERE date < DATE('2013-01-01')

更多推荐

本文发布于:2023-07-18 03:43:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1154192.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:日期   MySQL   date   count

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!