我的MySQL数据库是这样的:选择在UPDATE在同一个表
short -- idnumber--position
abc.......8765...........4
def........7453...........1
abc.......7398...........5
def........7542...........2
我有IDNumber中,想用相同的“短”为IDNumber中更新所有。更新应该是位置1。
我有IDNumber中:8765它的位置应该是3和ID 7398的位置应该是4
我怎么做是正确的?我的密码不工作,我没有回声
<?php
$pdo = new PDO('mysql:host=localhost;dbname=testdb1', 'root', '');
$idV = $_GET['id'];
$statement = $pdo->prepare("UPDATE idtabelle SET position = position-1 WHERE short IN
(SELECT short FROM idtabelle WHERE idnumber = :idV)");
$statement->bindParam(':idV', $idV);
$statement->execute();
while ($row = $statement->fetch(PDO::FETCH_ASSOC))
{
echo $row['short'];
};
?>
您运行的是'update'。没什么可抓取的.. – chris85