$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.
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);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.