我有一個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 –