it might work, but maybe the best way I can't think of right now
set @i = 0;
select
f.id,
@i:=@i+1 as i,
case
when c.counter <= 1 then f.name
else concat(f.name,'-',(@i % c.counter) +1)
end as name
from
foo f
join (select id, count(*) as counter from foo group by id) c on c.id = f.id
order by
f.id,name;
EDIT: , db