我需要使用IF
语句创建MySQL查询。这里是一个数据库模式:使用IF语句更新查询
CREATE DATABASE my_db;
USE my_db;
CREATE TABLE IF NOT EXISTS if_table(
id INTEGER unsigned,
field_1 INTEGER unsigned,
field_2 INTEGER unsigned,
field_3 INTEGER unsigned,
PRIMARY KEY (id)
);
我怎样写一个UPDATE
查询对应于下一个伪代码?
if field_2 equals 0 then field_1 = field_1 + 1
else field_3 = field_3 + 2
where id == 1
你的意思是更新? – xdazz
为什么倒票? – ashim