0

I want to implement a web app with php and mysql, to book an hotel and I want to create a constraint so the date of departure cannot be before the arrival date here are the method that I've tried without success : ALTER TABLE reservation WITH CHECK ADD CONSTRAINT CONSTRAINT check_dates CHECK ( DATEARRIVEE < DATEDEPART) messe error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CHECK ADD CONSTRAINT CONSTRAINT check_dates

kamel berkani
  • 57
  • 1
  • 6

1 Answers1

0

I suggest you to do the checks back-end side in your php code before inserting records in the table and front-end side with js. If the arrival date is > of the departure date you don't have to make a request to your server, so your js must handle this problem. For more security just before execute the query you can add another check.