简体   繁体   English

根据条件更新表和SET列

[英]UPDATE table and SET column based on condition

This is how my code looks now: 这是我的代码现在的样子:

$stmt = $link->prepare("UPDATE product SET product_price_lowest = $adPrice WHERE product_id = $prodId");
$stmt->execute();


I want to SET product_price_lowest TO $adPrice only: 我想设置 product_price_lowest $ adPrice:
IF $adPrice < product_price_lowest 如果 $ adPrice < product_price_lowest


How can I do this? 我怎样才能做到这一点?

Then add that to WHERE clause as well like 然后将其添加到WHERE子句中

WHERE product_id = $prodId
AND $adPrice < product_price_lowest

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM