mysql 触发器 分行_mysql 触发器
mysql 觸發器中有兩個insert 語句 第二個inert 要用第一個insert 的結果怎么實現
DELIMITER $$
USE `nightclub`$$
DROP TRIGGER /*!50032 IF EXISTS */ `create_histroy_room_statuses`$$
CREATE
/*!50017 DEFINER = 'root'@'localhost' */
TRIGGER `create_histroy_room_statuses` BEFORE DELETE ON `room_statuses`
FOR EACH ROW
BEGIN
INSERT `nightclub`.histroy_room_statuses (
room_id,
note,
customer_number,
arrival_time,
room_game,
drinks,
booking_time,
estimated_time,
assistant_table,
visitor,
cadres_patrol,
salesman_tip,
master_tip,
princess_tip,
drink_total,
prs_tip_total,
towel_number,
consume,
pay_method,
princess_customer_tel,
princess_customer_name,
createdAt,
updatedAt,
booking_employee_id,
princess_id,
salesman_id,
master_id,
booking_customer_tel,
booking_customer_name,
state,
enter_time
) SELECT
room_id,
note,
customer_number,
arrival_time,
room_game,
drinks,
booking_time,
estimated_time,
assistant_table,
visitor,
cadres_patrol,
salesman_tip,
master_tip,
princess_tip,
drink_total,
prs_tip_total,
towel_number,
consume,
pay_method,
princess_customer_tel,
princess_customer_name,
createdAt,
updatedAt,
booking_employee_id,
princess_id,
salesman_id,
master_id,
booking_customer_tel,
booking_customer_name,
state,
enter_time
FROM `nightclub`.room_statuses
WHERE room_id = old.room_id;
INSERT INTO histroy_room_status_prs (
employee_id,
room_id,
createdAt,
updatedAt,
customer_name,
customer_tel,
isExemptFee,
charge,
work_time
) SELECT
employee_id,
room_id,
createdAt,
updatedAt,
customer_name,
customer_tel,
isExemptFee,
charge,
work_time
FROM
room_status_prs WHERE room_id=old.room_id;
END;
$$
DELIMITER ;
histroy_room_status_prs 表我建立外鍵 但是獲取不到第一個insert 返回的值 該怎么實現 那位高手指點一下謝謝
總結
以上是生活随笔為你收集整理的mysql 触发器 分行_mysql 触发器的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Java在使用时需要注意那些问题_jav
- 下一篇: java kafka 设置分区_Java