You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何编写带多条件的UPDATE语句实现GearLevel与BankMoney联动更新?

Fixing Your Multi-Condition UPDATE Query

Hey there! I see where the issue is with your test query—you forgot to add a WHERE clause to target only the specific row you want, which is why it was modifying every row in the table. Let's get that sorted out.

The Correct Query

To update only the row that meets all three of your conditions (matching UID, BankMoney = 25000000, and GearLevel = 15) and perform both value changes at once, use this query:

UPDATE PlayerInfo
SET GearLevel = GearLevel + 1,
    BankMoney = BankMoney - 15000000
WHERE UID = "76561198008596823"
  AND BankMoney = 25000000
  AND GearLevel = 15;

How It Works

  • The WHERE clause filters down to exactly the row you care about—no more accidental updates to other players' data.
  • The SET clause handles both updates in one go: incrementing GearLevel by 1 and subtracting 15000000 from BankMoney. Since we've already filtered the row with the WHERE conditions, we don't need a CASE statement here (that was causing the broad update when no WHERE was present).

Quick Safety Tip

Before running any UPDATE query, it's always smart to verify which rows will be affected first with a SELECT:

SELECT *
FROM PlayerInfo
WHERE UID = "76561198008596823"
  AND BankMoney = 25000000
  AND GearLevel = 15;

This lets you confirm only the intended row is selected before making changes.

内容的提问来源于stack exchange,提问作者Mokey

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 07:35:01