MySQL 如何通过触发器内的“新”命令选择它们之间有空格的属性

问题描述 投票:0回答:1

我的房间表中有一个名为“最大座位数”的属性,但我不知道如何在插入后通过触发器访问它时选择/访问它。

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

如果更改属性名称不是一个选项,我如何选择

new.'Maximum Seats'
new.Maximum_Seats
new.MaximumSeats
.

mysql triggers phpmyadmin
1个回答
0
投票
new.`Maximum Seats`

就像在您的插入中一样,但由新的限定。

© www.soinside.com 2019 - 2024. All rights reserved.