1 つのテーブルから ID の範囲を選択し、それらをトランザクション ループに通して一度に 1 つのレコードを更新する最良の方法は何ですか?
$result = mysql_query('SELECT p_code FROM replenishment ');
$ids = array();
while ($p_code = mysql_fetch_row($result)) {
$ids[] = $p_code[0];
foreach($ids as $p_code) {
mysql_query('SELECT @A:=replenishment.p_code,@B:=replenishment.model
from replenishment
left join replenishment1 on replenishment1.p_code = replenishment.p_code
where replenishment.branch=10
and replenishment.p_code=$p_code
and replenishment.stock < min
and replenishment1.stock > 0
group by replenishment.p_code');
mysql_query('UPDATE replenishment1
SET stock = (stock - @B), B5=(b5+@B) WHERE @A = replenishment1.p_code
and replenishment1.stock >= @B');
$row = mysql_fetch_assoc();
}
}