update user_table a , (select max(user_id) as user_id from user_table) b set a.regist_time=curdate() where a.user_id=b.user_id
触发器有个约束就是不能对本身的表进行操作,试试下面这个 /*==============================================================*/ /* TRIGGER: chat_content_trig chat_content insert用 */ /*==============================================================*/ CREATE TRIGGER chat_content_trig after insert ON chat_content FOR EACH ROW BEGIN new.chat_time=sysdate(); END;
update user_table set regist_time =(select curdate()) where user_id=(select max(user_id) from user_table);
我觉得 我得重新描述下
因为我的chat_content_id是自增长的 所以 不会出现在insert语句里 然后 我想每次执行insert的时候 将insert所属行的chat_time进行更新
考虑到from_id和to_id都是不唯一的 只有chat_content_id是唯一的 所以呢 我纠结住了
set a.regist_time=curdate()
where a.user_id=b.user_id
/*==============================================================*/
/* TRIGGER: chat_content_trig chat_content insert用 */
/*==============================================================*/
CREATE TRIGGER chat_content_trig after insert
ON chat_content FOR EACH ROW BEGIN
new.chat_time=sysdate();
END;
建议参考一下MYSQL官方免费手册中的语法。