Reputation: 3293
I have a table with two columns:
assign_date | complete_date
----------------------------
2004-04-23 | 2005-05-13
... | ...
The dates are in the format yyyy-mm-yy.
When I am inserting a new row, I always want the complete_date to be at or after the assign_date. So if a row had an assign_date of 2013-10-10, 2013-10-09 would be invalid. Is there a way to do this in mysql without using triggers?
Upvotes: 1
Views: 45
Reputation: 562250
No, you must use a trigger to enforce this rule in the database.
Some people validate in their application before inserting the row. But this is error-prone because developers can forget to do the check in every case of inserting or updating data. Or someone can update the data directly without using an application.
Upvotes: 1