I am assuming that you want to match each phone number to the cost that has the longest prefix. Here is an approach:
select ir.*,
(select callcost
from int_rates ir
where r.calledno like concat(ir.dialcode, '%')
order by length(ir.dialcode) desc
limit 1
) as TheirCost
from 18185_rates r;
This is using a correlated subquery to find the longest dialcode that matches the beginning of the call. This will be NULL
if nothing matches. Also, this will not be efficient and cannot use indexes.
EDIT:
There are different ways to approach this. The simplest is just to duplicate the subquery:
select ir.*,
(select callcost
from int_rates ir
where r.calledno like concat(ir.dialcode, '%')
order by length(ir.dialcode) desc
limit 1
) as TheirCost,
(select description
from int_rates ir
where r.calledno like concat(ir.dialcode, '%')
order by length(ir.dialcode) desc
limit 1
) as TheirDescription
from 18185_rates r;
In practice, I would pull a primary key out in the first subquery and then join back to the table, to get whatever fields I want from the that table. However, you don't specify the table layout and if the first query has reasonable performance, then doing it twice should be ok too.