Mysql when case 批量更新
时间:2021-07-01 10:21:17
帮助过:26人阅读
=
array(
1 => 4,
2 => 1,
3 => 2,
4 => 3,
5 => 9,
6 => 5,
7 => 8,
8 => 9
);
$ids =
implode(‘,‘,
array_keys(
$display_order));
$sql = "UPDATE categories SET display_order = CASE id "
;
foreach (
$display_order as $id =>
$ordinal) {
$sql .=
sprintf("WHEN %d THEN %d ",
$id,
$ordinal);
}
$sql .= "END WHERE id IN (
$ids)"
;
echo $sql;
学习参考: https://blog.csdn.net/xiaoxiaodongxie/article/details/51773219
Mysql when case 批量更新
标签:article HERE title mysql when color end 行数据 dong