MYSQL DAY-1

时间:2014-01-17 17:35:56

标签: mysql events

经过大量搜索,我在这里发帖,因为我找不到答案。

我正在尝试创建一个mysql事件,每隔午夜更新一次我的表,并在日期等于昨天的数字时更改字段。

示例:

------------------------------                          ------------------------------
| id | day | month | expired |   If today is the 13     | id | day | month | expired |
------------------------------   and now are the        ------------------------------
|  1 |  12 |     1 |       0 |   00:01 it would have    |  1 |  12 |     1 |       1 |
------------------------------   to become like this    ------------------------------
|  2 |  13 |     1 |       0 |                  --->    |  2 |  13 |     1 |       0 |
------------------------------                          ------------------------------

这是我将用于触发事件的查询,但我不知道如何仅使用day = current_day_number - 1 and month = current_month_number更新行。

CREATE EVENT cl_reservations
ON SCHEDULE EVERY 1 DAY  
STARTS '2014-1-18 00:00:01'   
DO UPDATE `jc_classes`.`cl_reservations` SET `expired` =  '0' WHERE ???

非常感谢任何帮助= D

0 个答案:

没有答案