简体   繁体   English

我的存储过程中有错误

[英]Error in my stored-procedure

i have an error in my stored-procedure. 我的存储过程有错误。 I use MySql DB 我使用MySql DB

SET @counter = 1;
SET @last = 0;
UPDATE Customer SET ordre = (IF(@last = customer_id,@counter + 1,@counter = 1)),
                 @last = customer_id

My Error 我的错误

Script line: 3 You have an error in your SQL syntax; 脚本行:3您的SQL语法有错误; check the manual that corresponds to your MySQL server version for the right syntax to use near '@last = customer_id ORDER BY customer_id' at line 2 检查与您的MySQL服务器版本相对应的手册以获取正确的语法,以在第2行的'@last = customer_id ORDER BY customer_id'附近使用

You cannot set variables in SET clause of UPDATE statement. 您不能在UPDATE语句的SET子句中设置变量。 '@last = customer_id' causes the error. '@last = customer_id'导致错误。

From the reference - 从参考-

UPDATE syntax - '...SET col_name1=expr1 [, col_name2=expr2 ...]' UPDATE语法-'... SET col_name1 = expr1 [,col_name2 = expr2 ...]'

The SET clause indicates which columns to modify and the values they should be given. SET子句指示要修改的列以及应提供的值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM