select id, count(0) as match_count from tablename
where keyword in (...)
group by id
order by match_count desc
$(function(){
$('body').delegate('[href^=#tab]', 'click', function(){
alert($(this).attr('id'));
});
$('a#2').trigger('click');
});