cuốn sách gpt4 ai đã làm

MySql - 更新/案例

In lại Tác giả: Walker 123 更新时间:2023-11-29 02:17:54 26 4
mua khóa gpt4 Nike

我有一个表测试

TestNumber (int primary key)
InactiveBitwise (int)

我执行以下命令:

UPDATE tests SET CASE
WHEN TestNumber = 2 THEN InactiveBitwise = (InactiveBitwise | 4)
WHEN TestNumber = 3 THEN InactiveBitwise = (InactiveBitwise | 8)
END WHERE TestNumber IN (2, 3)

但它给出了错误

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CASE WHEN TestNumber = 2 THEN InactiveBitwise = (InactiveBitwise |'

TestNumber = 2 和 3 都存在,因为我之前通过调用数据库获得了它们。

有谁知道它不喜欢什么?

câu trả lời hay nhất

您需要指定要更改的列的值,大小写将仅确定返回值:

UPDATE tests SET InactiveBitwise = CASE
WHEN TestNumber = 2 THEN (InactiveBitwise | 4)
WHEN TestNumber = 3 THEN (InactiveBitwise | 8)
END
WHERE TestNumber IN (2, 3)

关于MySql - 更新/案例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36651079/

26 4 0
Walker 123
Hồ sơ

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá taxi Didi miễn phí
Phiếu giảm giá taxi Didi
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress