mysql查询赋值、修改拼接字符串

时间:2024-03-07 21:25:44

sql中修改字符串类型的字段可以这么拼接:update tbName set UserName=\'abc\'+UserName;

但mysql中就不行了,需要这样:update tbName set UserName=CONCAT(\'abc\',UserName);

 

把查询出来的多个值,赋值给多个变量,

sql:SELECT @oldOrderId=M_ORDERID,@oldParentId=M_PARENTID,@oldOrderPath=M_ORDERPATH FROM S_Menu WHERE M_ID=id;

mysql:SELECT M_ORDERID,M_PARENTID,M_ORDERPATH INTO oldOrderId,oldParentId,oldOrderPath FROM S_Menu WHERE M_ID=id;

sql中声明变量要加@,mysql中不用加@。