Reputation: 17
I'm trying to make this trigger work for the two columns I have in my table, can anyone help me? MariaDB only supports one trigger per table.
begin
if (select count(*) from reservation where res_room = new.res_room) > 3 then
signal sqlstate '45000';
END if;
END
This is my merge attempt:
begin
if (select count(*) from reservation where res_room = new.res_room) > 3 then
signal sqlstate '45000';
if (select count(*) from reservation where res_time = new.res_time) > 8 then
signal sqlstate '45000';
END if;
END
Upvotes: 0
Views: 36
Reputation: 1269873
I think the syntax you want is:
BEGIN
if (select count(*) from reservation where res_room = new.res_room) > 3 then
signal sqlstate '45000';
elseif (select count(*) from reservation where res_time = new.res_time) > 8 then
signal sqlstate '45000';
END if;
END
That is, you want elseif
.
Upvotes: 1