2 votes

Eun a SQL database how to make a field in a table accept only certain values

I have the following problem I want the role field to only accept two values 'USER_ROLE' or 'ADMIN_ROLE' as it could?, which I try unsuccessfully:

0voto

Noob Dev Points 15

I think the best implementation is for your field to be of the type ``

For example, in a Laravel migration, you would have ``

Or in an SQL statement: ``

0voto

Luis Cazares Points 1088

The problem is that you need to have the full comparison on both sides of the `` , since only Boolean data is compared.

HolaDevs.com

HolaDevs is an online community of programmers and software lovers.
You can check other people responses or create a new question if you don't find a solution

Powered by:

X