mysql - 关于Mysql中当前日期的比较

标签 mysql

我正在编写下面指定的查询,它没有错误,但没有获取与服务器当前日期匹配的正确记录,在其他部分它显示了旧记录

我的Mysql查询:

select news_title,
    full_url,
    source_site,
    date_added,
    `category`
from tbl_urlLog
where category like '%enter%'
    or category like '%hollywood%'
    or category like '%bollywood%'
    or category like '%movies%'
    or category like '%film%'
    and date (`date_added`) = date (CURDATE())
group by `source_site`
order by `date_added` desc LIMIT 3

最佳答案

我猜您想使用括号将所有 OR 组合在一起。另外,curdate() 已经是日期,无需对其调用date()

select news_title,
    full_url,
    source_site,
    date_added,
    `category`
from tbl_urlLog
where (
        category like '%enter%'
        or category like '%hollywood%'
        or category like '%bollywood%'
        or category like '%movies%'
        or category like '%film%'
        )
    and date (`date_added`) = CURDATE()
group by `source_site`
order by `date_added` desc LIMIT 3

关于mysql - 关于Mysql中当前日期的比较,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43176852/

相关文章:

python - MySQL-Python 代码将 `' 添加到数据库名称

php - Laravel 选择具有唯一列的行

php - GROUP BY 不能很好地工作

mysql - SQL:从右边开始的子串

mysql - 使用 groupby 和 orderby 进行 MySQL 查询的性能问题

php - 想在报告中看到 SQL 错误

mysql - 基于条件显示表中值的简单 SQL 查询

mysql - 网络消息系统的数据库结构

php - 如何在 php 代码中编写 jquery 代码

mysql - 为每个名称选择最新记录