我想,同时增加了新的进入我的logbook
start_date
和start_time
复制到latest_time
和latest_date
,
。
但是我也想依赖于logbook.logbook_index_id = logbook_index.id
所有条目。我想更新的其他表,当我创建一个条目
mysql> describe logbook;
+-------------------------------+-----------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------------------------+-----------------------+------+-----+---------+----------------+
| id | int(10) unsigned | NO | PRI | NULL | auto_increment |
| logbook_index_id | int(10) unsigned | NO | | NULL | |
| start_date | date | NO | | NULL | |
| start_time | time | NO | | NULL | |
mysql> describe logbook_index;
+--------------------+----------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------------------+----------------------+------+-----+---------+----------------+
| id | int(10) unsigned | NO | PRI | NULL | auto_increment |
| first_date | date | NO | | NULL | |
| first_time | time | NO | | NULL | |
| latest_date | date | NO | | NULL | |
| latest_time | time | NO | | NULL | |
+--------------------+----------------------+------+-----+---------+----------------+
ATM我走到这一步......
create trigger update_dates after insert on logbook
for each row update logbook_index
set latest_date = start_date where logbook_index.id = logbook_index_id;
我这样做,主要是错了,我敢打赌。这是如何正确工作的,以及如何获得复制时间?
我试过你说的,但现在我有一个新问题。帖子已更新。 – suleiman
我会更新我的回答 – RMT