SQL语句如下:
set @vl=(SELECT Stress FROM `account`.`Servers` WHERE ServerId = 1);
set @vl=@vl+1;
update `account`.`Servers` Set Stress = @vl where ServerId = 1;错误提示如下:
strError = You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 
'\set @vl=@vl+1;\update `account`.`Servers` Set Stress = @vl where ServerId = 1' at line 1说明:
我在mysql的客户端软件运行上面的代码是没有问题的,但是放到程序里面用mysql_query去执行的时候报那个错误,高手请指点。

解决方案 »

  1.   

    update `account`.`Servers` Set Stress = (SELECT Stress FROM `account`.`Servers` WHERE ServerId = 1)+1 where ServerId = 1
      

  2.   

    你的完整语句是什么? 仅从你这三句看,应该没有问题。另外实现相同语义,为什么不直接用下面这一句搞定?update `account`.`Servers` Set Stress = Stress+1 where ServerId = 1;
      

  3.   

    这个是可以,我是想学习使用set这个方法,sql解释器是没有问题,但是到代码里面就出问题了。