关于mysql:SQL WHERE on now()无法正常工作?

SQL WHERE on now() not working correctly?

我有以下问题……

1
SELECT fixture_date FROM tbl_foot_games WHERE fixture_date < now() AND leagueid = '68' AND (type = '2' OR type = '12' OR type = '22' OR type = '32') GROUP BY fixture_date ORDER BY fixture_date

这将输出以下内容….

1318876658
1319135858
1319395058
1319654258
1319913458
1320176258
1320435458
1320694658
1320953858
1321213058
1321472258

所有这些时间戳现在都在前面。知道为什么输出什么吗?

但是,我需要将now()改为3天。72小时!

有什么想法吗?谢谢:)


尝试:

1
2
3
4
5
6
7
SELECT fixture_date
FROM tbl_foot_games
WHERE FROM_UNIXTIME(fixture_date) < NOW()
  AND leagueid = '68'
AND type IN ('2', '12', '22', '32')
GROUP BY fixture_date
ORDER BY fixture_date

但是您不应该将时间戳存储为CHARVARCHAR


将查询更改为:

1
SELECT NOW(), fixture_date FROM tbl_foot_games ...

看看NOW()返回了什么。您的查询似乎是正确的(我觉得GROUP BY有点愚蠢…)。要请求将来的日期,请使用"日期"如下所示添加:

1
... WHERE fixture_date < DATE_ADD(NOW(), INTERVAL 3 DAY) ...