Using MySQL variables in a query
Posted
by Jon Tackabury
on Stack Overflow
See other posts from Stack Overflow
or by Jon Tackabury
Published on 2010-03-31T20:55:08Z
Indexed on
2010/04/02
9:53 UTC
Read the original article
Hit count: 205
mysql
I am trying to use this MySQL query:
SET @a:=0; UPDATE tbl SET sortId=@a:=@a+1 ORDER BY sortId;
Unfortunately I get this error:
"Parameter '@a' must be defined"
Is it possible to batch commands into 1 query like this, or do I need to create a stored procedure for this?
© Stack Overflow or respective owner