SwegreDesigns
SwegreDesigns

Reputation: 189

Limit the max number of rows in column MySQL

I have searched for a while now how to limit the number max number of rows in a table

I have made a registration system in phpmyadmin and when I come up to 60 users then no one can register anymore.

Hope this information helps, and I hope that you can help me!

I use phpmyadmin.

Here is a picture of what I want to limit to max 60 users to make it more clearer:

enter image description here

Upvotes: 1

Views: 1083

Answers (1)

Pethő Jonatán
Pethő Jonatán

Reputation: 308

CREATE TRIGGER check_user_number 
BEFORE INSERT ON users FOR EACH ROW
 BEGIN
      IF (SELECT COUNT(*) FROM users) >= 60
      THEN
           CALL 'Cannot add row, the number of users is limited to 60!';
      END IF;
 END;

Upvotes: 1

Related Questions