0

选择:

   SELECT pr.predmet            AS naziv_predmeta, 
           pr.protustranka_naziv AS protustranka 
    WHERE  pr.datetime > Date_add (Now(), INTERVAL 24 hour) 

我不断得到

1064 - 您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册以获取正确的语法,以便在第 3 行的 'WHERE pr.datetime > Date_add (Now(), INTERVAL 24 hour)' 附近使用

表结构:

protustranka_naziv varchar(255)
predmet varchar(255)
datetime datetime

编辑:好的,所以第一步是添加 FROM 子句 /facepalm。但问题是,我仍然不断收到错误消息。这是查询:

SELECT pr.predmet AS naziv_predmeta, pr.protustranka_naziv AS protustranka
FROM ou_predmeti
WHERE pr.datetime > DATE_ADD( NOW( ) , INTERVAL 24 HOUR ) 
LIMIT 0 , 30

这是消息:

1064 - 您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 4 行的 ') LIMIT 0, 30' 附近使用正确的语法

EDIT2:我又错过了,应该是FROM ou_predmeti pr

4

3 回答 3

1

你忘了你的FROM条款

SELECT pr.predmet AS naziv_predmeta, 
       pr.protustranka_naziv AS protustranka 
FROM ????
WHERE  pr.datetime > Date_add (Now(), INTERVAL 24 hour) 
于 2013-01-31T20:44:17.357 回答
1

你错过了重要的FROM条款:

SELECT pr.predmet            AS naziv_predmeta, 
       pr.protustranka_naziv AS protustranka 
FROM <TABLE-NAME-HERE> AS pr
WHERE  pr.datetime > Date_add (Now(), INTERVAL 24 hour) 
于 2013-01-31T20:44:24.187 回答
1

你缺少FROM条款

SELECT pr.predmet            AS naziv_predmeta, 
       pr.protustranka_naziv AS protustranka 
FROM your_table              AS pr
WHERE  pr.datetime > Date_add (Now(), INTERVAL 24 hour) 
于 2013-01-31T20:45:05.713 回答