I need to create a MySQL query with an IF statement. Here is a database schema:
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)
);
How do I write an UPDATE query which corresponds to next pseudo code?
if field_2 equals 0 then field_1 = field_1 + 1
else field_3 = field_3 + 2
where id == 1
Try this in-lineIFstatementor if you want to update the value,