Apologies if my wording is very awkward/non-fitting for a programmer - I'm just a SQL noob who's taking a beginners' class.
I'm using PHPMyAdmin to design an e-commerce database in which the minimum age of a customer is 18 yo. Because age is a calculated column, I want to record the DOB and enforce a CHECK constraint. I tried this but it didn't work:
CREATE TABLE Customer(
...
DOB date NOT NULL CHECK(DATEDIFF(year, CURDATE(), DOB))>=18),
...);
I got an error saying:
Function or expression 'curdate()' cannot be used in the CHECK clause of
DOB
Is there a way to enforce the MySQL CHECK constraint for calculated value?