mysql 批量更新如果一条条去更新效率是相当的慢, 循环一条一条的更新记录,一条记录update一次,这样性能很差,也很容易造成阻塞。...mysql 批量更新共有以下四种办法
1、.replace into 批量更新
replace into test_tbl (id,dr) values (1,'2'),(2,'3'),......(m,'yy');
update test_tbl, tmp set test_tbl.dr=tmp.dr where test_tbl.id=tmp.id;
注意:这种方法需要用户有temporary...4、使用mysql 自带的语句构建批量更新
mysql 实现批量 可以用点小技巧来实现:
UPDATE tableName
SET orderId = CASE id
WHEN...php中用数组形式赋值批量更新的代码:
$display_order = array(
1 => 4,
2 => 1,
3 => 2,
4 => 3,