我希望能够组合这三个更新语句,所以我不必单独运行它们。我通常会输入多个“产品”和多个“篮子”。
这个想法是能够基于“fieldB”在“5”和“10”之间或“fieldB”>“10”之间更新两个字段,而无需运行三个单独的查询。
非常感谢任何帮助。
UPDATE table
set fieldA = round(8.7 * fieldA,0),
fieldB = round(8.7 * fieldB,0)
where product in ('APPLE','BANANA')
and basket IN ('BROWN BASKET','RED BASKET','YELLOW BASKET','BLUE BASKET')
and fieldB < '5';
UPDATE table
set fieldA = round(4.3 * fieldA,0),
fieldB = round(4.3 * fieldB,0)
where product in ('APPLE','BANANA')
and basket IN ('BROWN BASKET','RED BASKET','YELLOW BASKET','BLUE BASKET')
and fieldB between '5' and '10';
UPDATE table
set fieldA = round(2.5 * fieldA,0),
fieldB = round(2.5 * fieldB,0)
where product in ('APPLE','BANANA')
and basket IN ('BROWN BASKET','RED BASKET','YELLOW BASKET','BLUE BASKET')
and fieldB > '10';