Click to See Complete Forum and Search --> : Field constraint in MySQL server


trivektor
07-19-2007, 12:18 AM
Hi,

Let say I have a table, with a field called Option. I want to put a constraint on Option such that it can only have value 0,1,2 or 3. So an input like -1 or 4 will cause an error. Can anyone please tell me how to do it? Thanks.

bubbisthedog
07-19-2007, 09:54 AM
If it's an input field, this is a potential JavaScript question. You could set up a simple client-side alert for the user if validation fails.

If it's a drop-down list, then research the 'IN' keyword.