Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想说的是:
if field_1 then set field_2 = 1
意思是,如果 field_1 持有真实值,请执行其他操作。sql中的IF语句可以执行这种求值吗?
如果 CASE WHEN 为真,则使用CASE WHEN THEN并将 field2 设置为 1,否则使用 ELSE将 field2 设置为之前的值。
CASE WHEN THEN
ELSE
UPDATE table SET field2 = CASE WHEN field1 IS NOT NULL THEN 1 ELSE field2 END;