-1
こんにちは、ansIDをパラメータとして取得し、UserテーブルとAnswerテーブルの両方の "score"フィールドを更新するプロシージャを作成しようとしています。ストアドプロシージャとMySQL変数
DELIMITER $$
CREATE PROCEDURE UpVoteAnswer(IN _ansID INT)
BEGIN
SET @_userID = SELECT user_id from Answers where id = _ansID;
UPDATE Answers SET score = score + 1 where id = _ansID;
UPDATE Users SET score = score + 1 where id = @_userID;
END
$$
DELIMITER ;
Error:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT user_id from Answers where id = _ansID;
UPDATE Answers SET score = score' at line 3
、問題は何ですか? – fancyPants
が更新されました。ありがとう。 – RStyle
あなたの 'SET'ステートメントに' SELECT'ステートメントを括弧で入れてください。 – fancyPants