Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DELIMITER //
- CREATE TRIGGER Carperperson
- BEFORE INSERT ON bookings
- FOR EACH ROW
- BEGIN
- IF NEW.customer_id = bookings.customer_id
- and ((new.start_date >= bookings.start_date and new.start_date < bookings.end_date)
- or (new.end_date > bookings.start_date and new.end_date < bookings.end_date))
- THEN
- SIGNAL SQLSTATE '45000' set message_text='You can only book one car per single customer a day!';
- DELIMITER;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement