1

I have this table:

CREATE  TABLE `sold` (
`part_ID` INT(11) NOT NULL ,
`date` DATE NOT NULL ,
 PRIMARY KEY (`part_ID`, `date`) ,
 FOREIGN KEY (`part_ID` )
 REFERENCES `part` (`part_ID` );

This table represent parts sold each day, constraint says number of sales should be at least 25 and at most 100. How can I implement this constraint?

I think it should start with something like this:

CHECK ( NOT EXISTS ...
hamid
  • 2,033
  • 4
  • 22
  • 42
  • @AshReva enforcing this constraint: number of sales should be at least 25 and at most 100. – hamid Mar 11 '13 at 19:04
  • Please don't cross-post: http://dba.stackexchange.com/q/36413/1822 –  Mar 11 '13 at 22:24

1 Answers1

1

try below

CONSTRAINT chk_sales CHECK (columnName>=25 AND columnName <=100)

Also refer this link

DevelopmentIsMyPassion
  • 3,541
  • 4
  • 34
  • 60