select title from ( 
    select title from {$dbtbpre}ecms_all where title like '%{$keyboard}%'
    union all 
    select title from {$dbtbpre}ecms_mtv where title like '%{$keyboard}%'
) t
order by LENGTH(title)-LENGTH(replace(title,'{$keyboard}','')) desc");