Reputation: 13
For all presidents born after 1800, the party can never be ’WHIG’.
alter table president
add constraint whig_check check (birth_year > 1800 and party <> 'WHIG');
It gives me that some row violates it but I checked and it doesn't. I think the system sees it as two seperate constraint but they should be together. How do I make it this work?
Upvotes: 0
Views: 783
Reputation: 657092
You got the logic backwards. use instead:
alter table president
add constraint whig_check check (birth_year <= 1800 OR party <> 'WHIG');
Upvotes: 1