关于Mysql中的当前日期比较

时间:2017-04-03 05:07:53

标签: 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

1 个答案:

答案 0 :(得分:0)

我猜你想用括号将所有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