0

I have an attribute called Maximum Seats in my Room Table but I do not know how to select/access it while accessing it through a trigger on AFTER INSERT.

ROOMS (RoomID, Maximum Seats)
Primary Key: RoomID

ROOM OCCUPANCY (RoomID, Seat Number)
Primary Key: RoomID
Foreign Key: RoomID References Rooms(RoomID)
CREATE TRIGGER auto_populate AFTER INSERT ON rooms
FOR EACH ROW
BEGIN
    DECLARE count INT;
    SET count = 1;
    WHILE count < new.Maximum_Seats do
    INSERT INTO `room occupancy` (`RoomID`, `Seat Number`) VALUES (new.RoomID, count);
    END WHILE;
END

In the event that changing the attribute name is not an option, how can I select new.'Maximum Seats' or new.Maximum_Seats or new.MaximumSeats.

Danial
  • 1
  • 2

1 Answers1

0
new.`Maximum Seats`

Just like in your insert, but qualified by new.

ysth
  • 96,171
  • 6
  • 121
  • 214