我正在尝试编写触发器,但是我有一些语法错误。 当我将下面的代码插入触发器时,出现了错误。但是我直接输入了,可以,为什么?
Select max(User_IDNum) into @IDnum from Users;
Create trigger IN_Users
before insert On Users
For each row
Begin
Select max(User_IDNum) into @IDnum from Users;//syntax error
Set @num = cast(right(@IDnum,2) as int) + 1;
Set @date = Date_format(Now(), '%y%m%d');
set New.User_IDNum = @date + right(‘00’+cast(@num as varchar) , 2);//syntax error
end;
你能帮我吗?我是MariaDB的新手。
谢谢!