我似乎无法使以下SQL代码正常工作:
UPDATE ip_port
SET
enabled = (case when fails > 5 then enabled = 0 else enabled end),
fails = (case when fails < 5 then fails = fails + 1 else fails end)
WHERE
proxy LIKE '%1.2.3.4:8080%'
基本上我正在尝试设置代码enabled = 0
如果fails > 5
,或fails < 5
然后添加1就失败了。
查询的第一部分工作在于,如果失败为6,则将enabled设置为0,但失败时的增量不起作用
答案 0 :(得分:1)
UPDATE ip_port
SET enabled = case when fails > 5
then 0
else enabled
end,
fails = case when fails < 5
then fails + 1
else fails
end
WHERE proxy LIKE '%1.2.3.4:8080%'