I am trying to make a procedure with arguments. But when I use them in a WHERE condition it is like there were never there. They are simply ignored.
DELIMITER //
DROP PROCEDURE IF EXISTS p //
CREATE PROCEDURE p (IN player TEXT, OUT num INT)
BEGIN
SELECT COUNT(*) INTO num FROM `sg_playerstats` WHERE `player` = player;
END
//
DELIMITER ;
Num gets filled correctly, but whatever I put in player, the result is ALWAYS 66. (The table has 66 rows!)
What am I doing wrong???
解决方案
rename your parameter,
CREATE PROCEDURE p (IN _player TEXT, OUT num INT)
BEGIN
SELECT COUNT(*) INTO num FROM `sg_playerstats` WHERE `player` = _player;
END
the reason why you are getting that is because it happens to have name collision.