Why do I keep getting the HY000 error (General error) with this query?
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
But if I remove the SET
statements it works correctly:
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
However, the same query works perfectly fine when run on MySQL Workbench, just by replacing ?
with the 11
. Is there something I'm missing while connecting to the DBMS or something?