如何通过带有准备好的语句的concat更新MySQL文本列?

问题描述 投票:-1回答:1

我正在尝试在数据库中将文本列与UPDATE连接起来,但是我无法在网上找到任何说明如何处理已准备好的语句的资源。我不断收到错误消息:“ syntax to use near '(admin_notes=?) WHERE id=?' at line 1

$sql = "UPDATE problem_report SET concat(admin_notes=?) WHERE id=?";
//Also tried "concat(admin_notes,?)"
$stmt = $conn->prepare($sql);
$stmt->bind_param("si", $note,$_POST['id']);
$stmt->execute();
php mysql sql-update prepared-statement concat
1个回答
1
投票

您正在尝试更新admin_notes列。您需要连接值而不是列本身。

“ UPDATE problem_report SET admin_notes = concat(admin_notes ,?)WHERE id =?”;

© www.soinside.com 2019 - 2024. All rights reserved.