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.
基本上我有一个名为“ispushed”的专栏。每当按下网页上的按钮时,该列中的所有值都应重置为零,除了我正在更新的行,该值应设置为 1。
像这样的东西
CREATE TRIGGER `TR_ispushed` BEFORE UPDATE on `questions` FOR EACH ROW BEGIN UPDATE questions set questions.`ispushed` = 0 WHERE id <> **Current id** END$$
触发器不是实现此类逻辑所需的。简单的更新语句就可以了:UPDATE questions SET is_pushed = CASE WHEN id =[your_id] THEN 1 ELSE 0 END;
UPDATE questions SET is_pushed = CASE WHEN id =[your_id] THEN 1 ELSE 0 END