If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > rookie question on "check" command

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-27-04, 05:33
damiano damiano is offline
Registered User
 
Join Date: Jan 2004
Posts: 2
rookie question on "check" command

does anybody know how to set a max limit to the values to be inserted in a column? I tried with

create table test (col1 varchar(10), col2 double check (col2 < 1));

but it doesn't works infact it accepts any value.
Thank you all.
Reply With Quote
  #2 (permalink)  
Old 01-27-04, 06:21
damiano damiano is offline
Registered User
 
Join Date: Jan 2004
Posts: 2
this seems to be a working solution:

mysql> update test set col2=col2+0.1 where col1=1 and abs(col2)<1;

when the value of col2 reaches 1 it stops being augmented

mysql> update test set col2=col2+0.1 where col1=1 and abs(col2)<1;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0 Changed: 0 Warnings: 0

mysql> select * from test;
+----+--------+
| col1| col2 |
+----+--------+
| 1 | 1 |
+----+--------+
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On