select id, title, type
from (select id, title, type,
@num := if(@group = type, @num + 1, 1) as row_number,
@group := type as dummy
from your_table
order by type, title) as x
where row_number <= 3
select id, title, type
from (select id, title, type,
@num := if(@group = type, @num + 1, 1) as row_number,
@group := type as dummy
from your_table
order by type, title) as x
where row_number <= 3