问题
$sqlcount1 ="SET uid = -1 UPDATE `agent_normal` SET `uid` = @a:=@a+1";
$result = mysqli_query($conn,$sqlcount1);
how to write this query in core php?
This query works in mysql but not in core php.
Here i want to update a single row of table and value should start from 0 and then should increment by 1.
回答1:
There are a couple of problems. Firstly, if you look at this answer you'll see you have an incorrect variable name and missing semicolon. The query should be :
$sqlcount1 ="SET @a = -1; UPDATE `agent_normal` SET `uid` = @a:=@a+1";
Secondly, to use two queries in one call you need to use mysqli_multi_query.
$result = mysqli_multi_query($conn,$sqlcount1);
来源:https://stackoverflow.com/questions/49827947/update-single-column-of-table-and-value-should-start-from-0-and-then-should-incr