I am new to MySQL triggers. i want to insert the newly inserted booking from booking table to bookings_clone table.
All the field in bookings table are filled but in bookings_clone only these fields are getting inserted (id, uniqueid, branch_id, user_id, status, sms_status, email_status, created_at, updated_at) and rest of them are null. Any help in pointing me to right direction is highly appreciated. The table structure of bookings_clone is same as bookings.
CREATE TRIGGER after_booking_insert AFTER INSERT ON bookings FOR EACH ROW INSERT INTO bookings_clone (id, unique_id, branch_id, pos_user_id, user_id, user_address_id, address, postcode, city, town, status, order_due_date, order_due_time, checkout_mode, sms_status, email_status, notes, time_taken, accepted_at, delivery_charges, discount_amount, total_charges, sub_total_charges, initiator, created_at, updated_at, deleted_at) VALUES (NEW.id, NEW.unique_id, NEW.branch_id, NEW.pos_user_id, NEW.user_id, NEW.user_address_id, NEW.address, NEW.postcode, NEW.city, NEW.town, NEW.status, NEW.order_due_date, NEW.order_due_time, NEW.checkout_mode, NEW.sms_status, NEW.email_status, NEW.notes, NEW.time_taken, NEW.accepted_at, NEW.delivery_charges, NEW.discount_amount, NEW.total_charges, NEW.sub_total_charges, NEW.initiator, NEW.created_at, NEW.updated_at, NEW.deleted_at);
I've also tried this but the result is same
DELIMITER // CREATE TRIGGER after_booking_inserted AFTER INSERT ON bookings FOR EACH ROW BEGIN INSERT INTO bookings_clone select * from bookings where id = NEW.id; END;// DELIMITER ;
Bookings Table Structure: