[英]Update single column of table and value should start from 0 and then should increment by 1
$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? 如何在核心php中编写此查询?
This query works in mysql but not in core php. 此查询在mysql中有效,但在核心php中无效。
Here i want to update a single row of table and value should start from 0 and then should increment by 1. 在这里我想更新表的单行,值应从0开始,然后应增加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 . 其次,要在一个调用中使用两个查询,则需要使用mysqli_multi_query 。
$result = mysqli_multi_query($conn,$sqlcount1);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.