如何在 mysql 中创建作业或事件

编程入门 行业动态 更新时间:2024-10-25 00:29:23
本文介绍了如何在 mysql 中创建作业或事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想在一天结束时运行的 mysql 中创建一个作业,在该作业中我想更新表中的一些列值.假设我有 2 个表,其中有一个名为 Status 的列,它是 Pending 或 Accepted.为此,我想创建一个工作,我想在其中搜索两个表并将 Pending 状态设置为 Accepted.

I would like to create a job in mysql which runs on the end of the day, where in that job I would like to update some of the column values in my tables. Assume I am having 2 tables where I am having a column named Status which is either Pending or Accepted. For this I would like to create a Job where I would like to search the two tables and set Pending status to Accepted.

有没有可能

推荐答案

使用 MySQL 的 事件调度程序:

Use MySQL's Event Scheduler:

DELIMITER ;; CREATE EVENT foo ON SCHEDULE EVERY DAY STARTS '2012-10-05 00:00:00' DO BEGIN UPDATE table1 SET Status = 'Accepted' WHERE Status = 'Pending'; UPDATE table2 SET Status = 'Accepted' WHERE Status = 'Pending'; END;; DELIMITER ;

更多推荐

如何在 mysql 中创建作业或事件

本文发布于:2023-10-25 08:06:59,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1526409.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:作业   事件   如何在   mysql

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!