-1


在更新同一表存储过程中的第一行或在表中更新后触发后更新第二和第三行表(使用mysql)

id |Is_executed | 准备好了  
1 | 0 |  
2 | | 0  
3 | | 0

如果我将 is_executed 更新为 id 的 '1' 为 1,那么我想要以下行更新

id |Is_executed | 准备好了  
1 | 1 |  
2 | | 1  
3 | | 1   

使用触发器或存储过程

4

1 回答 1

0

Your desired business logic isn't entirely clear from your question, but it sounds like you want a trigger along the following lines:

DELIMITER ;;

CREATE TRIGGER my_trigger AFTER UPDATE ON my_table FOR EACH ROW
  IF NEW.id = 1 AND OLD.Is_executed = 0 AND NEW.Is_executed = 1 THEN
    UPDATE my_table SET Is_Ready = 1 WHERE id IN (2,3);
  END IF
;;

DELIMITER ;
于 2013-09-26T09:32:50.473 回答