Reputation: 138
CREATE TABLE CUSTOMERS(
ID INT NOT NULL,
NAME VARCHAR (20) NOT NULL,
AGE INT NOT NULL CHECK (AGE >= 18),
ADDRESS CHAR (25) ,
SALARY DECIMAL (18, 2),
PRIMARY KEY (ID)
);
I have created table. But it allowed me to add age <18
.
How to solve it . I need to check age>=18
. how to write query for that?
Upvotes: 0
Views: 156
Reputation: 29166
The check command is parsed by all mysql storage engines. That's why it's not working. Either validate your data from PHP, or use a trigger, or use procedures to validate and insert data.
Upvotes: 1