P
P
player1_serg2014-08-10 14:16:34
MySQL
player1_serg, 2014-08-10 14:16:34

Is it possible to limit the number of records with a given key in mysql?

There is a table in the database that has a class column that can be repeated. How can I put a limit on the number of entries with the same class. I know that it is possible to create a trigger that, when inserted, will check the number of records with the selected class. But isn't there an easier way, something like ALTER TABLE MAX_ROWS?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey, 2014-08-11
@rdifb0

Perhaps you have another column on which, together with the class column, you can hang a unique key. But in most cases, it is simply pre-checked with an additional request.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question