Declaring and using MySQL varchar variables

前端 未结 4 850
醉话见心
醉话见心 2021-02-11 21:18

I\'m trying to do some simple manipulations with variables in MySQL 5.0 but I can\'t quite get it to work. I\'ve seen many (very!) different syntaxen for DECLARE/SET, I\'m not

4条回答
  •  礼貌的吻别
    2021-02-11 21:52

    Looks like you forgot the @ in variable declaration. Also I remember having problems with SET in MySql a long time ago.

    Try

    DECLARE @FOO varchar(7);
    DECLARE @oldFOO varchar(7);
    SELECT @FOO = '138';
    SELECT @oldFOO = CONCAT('0', @FOO);
    
    update mypermits 
       set person = @FOO 
     where person = @oldFOO;
    

提交回复
热议问题