Maximum number for a field in the database

Asked

Viewed 65 times

1

I would like to know if it is possible to limit a maximum value to a field, e.g.: I want the maximum level number to be 200 in the mysql database. it is possible this through an update, in which way this could be done?

  • 1

    You can do this before sending to the bank, in PHP itself, using a simple IF if ($valor <= 200) { mysqli_query('UPDATE ...'); } else { echo 'O tamanho ultrapassou o limite'; }

  • 1

    Constraint CHECK. https://dev.mysql.com/doc/refman/8.0/en/create-table-check-constraints.html

  • It didn’t work neither with me =/

1 answer

-1

The best would be to limit the programming because the database will store the same data space as in your case a 3-digit number. so it is better to use the value restriction in the data entry mask.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.