我只想重新分配一行(来自同一张表)和新行1
该表的列'版本'为AI
其他三列(name,arrayV,notes)
CURRENT FAILED ATTEMPT(只是sql语法,使用固定值而不是变量)
UPDATE `variables` AS v1, `variables` AS v2 SET v1.`name` = v2.`name`, v1.`arrayV` = v2.`arrayV`, v1.`notes` = v2.`notes` WHERE v1.`version`=1,v2.`version`= 5;
以前失败的尝试
$newAI1 = $_POST["newSet"];//variable is an integer equal to another row ('version') in table
echo "New set of is ".$newAI1."<br/>";
$sqlMove = "INSERT INTO `variables` (`name`,`arrayV`,`notes`) WHERE `version` = '1' (SELECT `name`,`arrayV`,`notes` FROM `variables` WHERE `version` = '".$newAI1."')";
我哪里错了?
答案 0 :(得分:1)
可能是这样的:
$sql = "update `variables` as v1, `variables` as v2 set v1.`name` = v2.`name`, ... where v1.`version`=1 and v2.`version`= '" .$newAI1 . "'"
$sqlDelete = "delete from `variables` where version='" . $newAI1. "'"
1)使用行$ newAI 1
中的值更新第1行2)删除行$ newAI 1