update config
set role = 'abc'
where id = '2'
and (select 1 from (
select 1 from config where role='abc' having count(1)<3
) t )
Update the role of id=2 in the config table to abc The precondition is that when the data in the table with the role of abc is less than 3