$x = 5;
$stmt = $db->prepare('UPDATE ' . $table. ' SET sort = sort + 1') ;
$stmt->execute();
如何仅针对sort
列中等于或高于$x
的值执行查询?
答案 0 :(得分:3)
只需将其添加到where语句:
$stmt = $db->prepare('UPDATE ' . $table. ' SET sort = sort + 1 where sort >= ?') ;
$stmt->bind(1, $x)