触发两个具有相同id mysql的表

时间:2017-03-22 05:20:37

标签: php mysql triggers phpmyadmin

我有两个MySQL表:

t_calibrator
------------------------------------------------------------------------
| id | id_calibrator | period  | callast    | calnext    | organizer   |
------------------------------------------------------------------------
| 1  | ST-0001       | 1 Year  | 2016-12-30 | 2017-12-29 | LIPI        |
------------------------------------------------------------------------
| 2  | ST-0002       | 6 Month | 2016-11-12 | 2017-05-11 | Kaliman     |
------------------------------------------------------------------------
| 3  | ST-0003       | 6 Month |     -      |      -     |      -      | 
------------------------------------------------------------------------

t_history
--------------------------------------------
| id | idcalibrator | purpose    | sign    |
--------------------------------------------
| 1  | ST-0001      | 2016-12-30 | LIPI    |
--------------------------------------------
| 2  | ST-0002      | 2016-11-12 | Kaliman |
--------------------------------------------
| 3  | ST-0003      | 2017-01-13 | Delta   | *new data
--------------------------------------------
| 4  | ST-0001      | 2017-01-10 | Delta   | *new data
--------------------------------------------

其中id_calibrator = idcalibrator,callast = purpose和organizer = sign。如果我在表t_history中输入新数据,则表t_calibrator将会更新:

t_calibrator
------------------------------------------------------------------------
| id | id_calibrator | period  | callast    | calnext    | organizer   |
------------------------------------------------------------------------
|  1 | ST-0001       | 1 Year  | 2017-01-10 | 2018-01-09 | Delta       |
------------------------------------------------------------------------
|  2 | ST-0002       | 6 Month | 2016-11-12 | 2017-05-11 | Kaliman     |
------------------------------------------------------------------------
|  3 | ST-0003       | 6 Month | 2017-01-13 | 2017-07-12 | Delta       |
------------------------------------------------------------------------

我正在尝试创建一个触发器,但总是出错,需要帮助。

0 个答案:

没有答案