MySQL为日期查询返回了一个空结果

时间:2017-07-10 20:26:47

标签: mysql sql

查询MYSQL以获取' current_date'中的记录今天的日期,' No'查询日期返回数据。相反,它返回

"MySQL returned an empty result set (i.e. zero rows). ( Query took 0.0004 sec )" 

已尝试且以下查询均未返回任何记录。

TRIED SQL QUERIES:

SELECT hash FROM malware_db WHERE current_date like '%2017-07-10%'

SELECT hash FROM malware_db WHERE date(current_date) like '%2017-07-10%'
SELECT hash FROM malware_db WHERE date(current_date) between date('2017-07-10 00:00:00') AND date('2017-07-10 23:59:59') 

SAMPLE DB RECORDS

hash,first_seen,last_seen,current_date,status,treat,trust,name,famil,generic,platform,subplatform,mType,scannerPercent

9dc1a6770bf57142bbfb9428b3e6213e,2014-06-10 22:01:00,2017-07-02 18:10:00,2017-07-10 23:06:23,MALICIOUS,5,5,Android.Exploit.Lotoor,Lotoor,False,Android,None,None,57.1428565979

在" Type"的结构current_date中列是" datetime" 。

不确定,这里有什么问题?有什么建议吗?

2 个答案:

答案 0 :(得分:1)

SELECT hash FROM malware_db WHERE DATE( current_date ) = '2017-07-10'

但这听起来好像你没有找到合适的数据库/表格,因为所有这些建议都应该有效。

答案 1 :(得分:1)

select hash from malware_db where date(current_date) = date(now());