Executing the following query in MySQL v8.0.13 results in this error:
0 row(s) affected, 1 warning(s): 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Please set variables in separate statements instead.
SET @i = -1;
UPDATE `tb_test`
SET `order` = (@i := @i + 1)
ORDER BY `order` ASC;
Any suggestions on how to set the variables in a separate statement?
This is really a shot in the dark (never used mySQL), but checking the docs it says:
"Support for setting user variables in statements other than SET was deprecated in MySQL 8.0.13. This functionality is subject to removal in MySQL 9.0."
(Emphasis mine).
So maybe the problem is that you increment @i without using SET? Can you rewrite this with an explicit SET and see if it helps?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With