我当前的echo $sql;
返回两个查询:
UPDATE 00001 SET discount=11, discount_price=166.43, discount_price=166.00 WHERE code=00001070170UPDATE 00001 SET discount=11, discount_price=166.43, discount_price=166.00 WHERE code=00001070171
我想知道如何将它们分开并添加;在每个结尾处。 我的$ sql命令如下:
$sql = ("UPDATE ".$row['sku']." SET discount=".$discount1.", discount_price=".$discount_price1.", discount_price_elite=".$discount_price." WHERE code=".$row['code']."");
预期的输出是:
UPDATE 00001 SET discount=11, discount_price=166.43, discount_price=166.00 WHERE code=00001070170;
UPDATE 00001 SET discount=11, discount_price=166.43, discount_price=166.00 WHERE code=00001070171
答案 0 :(得分:1)
不要尝试将它们合并为一个查询,而是将它们作为单独的查询进行:
foreach ($rows as $row) {
$sql = "UPDATE ".$row['sku']." SET discount=".$discount1.", discount_price=".$discount_price1.", discount_price_elite=".$discount_price." WHERE code=".$row['code'];
mysqli_query($mysqli, $sql);
}
顺便说一句,对于每个SKU都有一个单独的表是一个非常奇怪的数据库设计。通常应该只有一个products
表和一个sku
列。