We have a table where we limit the number of rows per user to a certain number. Before insert, we check if user has exceeded the storage capacity (number of rows) and then insert as appropriate. For example,
select count(id) from items where user=123;
say, if count < 10,
insert into items set user=123, a=xyx;
However, this approach requires two queries. Is there a way in which is can be done in a single query.
Thanks