在MYSQL
中查询“current_date”中包含今天日期的记录时,查询的日期返回“无”数据。相反,它返回为
"MySQL returned an empty result set (i.e. zero rows). ( Query took 0.0004 sec )"
尝试过以下查询,但均未返回任何记录。
尝试过的 SQL 查询:
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')
示例数据库记录
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
在该结构中,“current_date
”列的Type
为“datetime
”。
不确定,这里有什么问题?请问有什么建议吗?
最佳答案
select hash from malware_db where date(current_date) = date(now());
关于MySQL 返回日期查询的空结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45021002/