php – DATEADD在我的查询中不起作用

我有一个问题,我无法弄清楚解决方案.使用之前提出的问题(SELECT rows with time 30 minutes or less?)我试图使我的COUNT(*)函数工作,但我无法使它工作.有人有想法吗?

$adViewUnique = $dbh->query('SELECT COUNT(*) FROM g_ad_view WHERE ad_view_time >= DATEADD(mi, -30, GETDATE())')->fetchColumn();

这是我回来的错误:

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1305 FUNCTION 18RVS15.DATEADD does not exist' in /var/www/vhosts/revulsionfm.com/RVS2.0/widgets/advertisement.php:38 Stack trace: #0 /var/www/vhosts/revulsionfm.com/RVS2.0/widgets/advertisement.php(38): PDO->query('SELECT COUNT(*)...') #1 {main} thrown in /var/www/vhosts/revulsionfm.com/RVS2.0/widgets/advertisement.php on line 38
最佳答案
MySQL语法是:

WHERE ad_view_time >= now() - interval 30 minute

转载注明原文:php – DATEADD在我的查询中不起作用 - 代码日志