MYSQL,触发器,实现多个表共用ID不重复
时间:2021-07-01 10:21:17
帮助过:41人阅读
TRIGGER IF EXISTS `InsertUser`;
create trigger InsertUser
before insert on userinfo
for each row
Begin
declare id
int;
insert into user values (
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL);#让自动增长的表插入失败,ID作废,就可以让触发器的表使用
select id
into @id from user order by id
desc limit
1;
set new.id
= @id;
end;
MYSQL,触发器,实现多个表共用ID不重复
标签:bsp desc row pre class get 实现 nbsp 自动