HY000使用PDO准备好的声明上的一般错误

时间:2014-12-19 18:20:00

标签: php mysql pdo

为什么我一直在使用此查询获取HY000错误(常规错误)?

SET  @uid:=?;
SET  @uscore:=(SELECT `total_score` FROM `user` WHERE `user_id` = @uid LIMIT 1);

SELECT `user_id`, `username`, `total_score` FROM `user`
WHERE `total_score` > @uscore
OR `user_id` = @uid
OR `total_score` < @uscore
ORDER BY `total_score` DESC
LIMIT 11

但如果我删除了SET语句,它就能正常工作:

SELECT `user_id`, `username`, `total_score` FROM `user`
WHERE `total_score` > 5000
OR `user_id` = 11
OR `total_score` < 5000
ORDER BY `total_score` DESC
LIMIT 11

然而,只需将?替换为11,在MySQL Workbench上运行时,同样的查询就可以正常运行。在连接到DBMS或其他什么东西时,我有什么遗漏吗?

0 个答案:

没有答案