I’ve simple example to describe my problem. Lets say I’ve table structured like this =>
create table A(
id INT(3) NOT NULL AUTO_INCREMENT PRIMARY_KEY,
act DATETIME,
act_reset INT(1) DEFAULT 0);
I want to write query with condition that if act_reset is true (so if not 0) then update column act DATETIME.
I’ve tried it like this=>
IF act_reset THEN UPDATE A SET act=now() WHERE id=1 END IF;
but this syntax is not valid, how I must write this condition with one query ? thanks
Is this the query you are looking for?
Using If statement in MySQL :