我有一个MySQL表,它看起来像这样。如何根据条件更新列
+----------+-----------+----------+--------------+-------------+
| PONO | ItemCode | OrderQty | ReflectedQty | OtherStatus |
+----------+-----------+----------+--------------+-------------+
| PO787HZN | HKQSLUWKN | 30.00 | 30.00 | Posted |
| PO787HZN | SORHFRBPJ | 40.00 | 40.00 | Posted |
| PO787HZN | OP8XMREC0 | 50.00 | 50.00 | Posted |
| PO787HZN | CPD5CGDZ3 | 60.00 | 60.00 | Posted |
+----------+-----------+----------+--------------+-------------+
,并随着时间的推移列ReflectedQty
将被更新,它可能看起来像这样
+----------+-----------+----------+--------------+-------------+
| PONO | ItemCode | OrderQty | ReflectedQty | OtherStatus |
+----------+-----------+----------+--------------+-------------+
| PO787HZN | HKQSLUWKN | 30.00 | 20.00 | Posted |
| PO787HZN | SORHFRBPJ | 40.00 | 1.00 | Posted |
| PO787HZN | OP8XMREC0 | 50.00 | 5.00 | Posted |
| PO787HZN | CPD5CGDZ3 | 60.00 | 6.00 | Posted |
+----------+-----------+----------+--------------+-------------+
我的问题是如何能够更新列OtherStatus
到Partially Received
或Fully Received
如果列ReflectedQty
= 0.00
?
我怎样才能实现这个使用选择命令?
我将代码解释这个(样品)
sqlcommand = select reflectedqty from table where reflectedqty = 0.00 and PONo = PO787HZN
if all ReflectedQty of PO787HZN = 0.00 then
'Update OtherStaus to = Fully Received
else
'Update OtherStaus to = Partially Received
end if
任何其他代码接受
TYSM
什么valuetobededucted? –
我猜想你通过这个作为输入,而从ReflectedQty中扣除。总之,它是一个输入参数。顺便说一下,你想一次更新所有的行吗?然后看看第二个查询 – 1000111
TYSM的帮助先生:)我做了一些更新与第二个代码,因为它为我工作的一个。 TYSM –