SELECT Numbers.number,
Tariffs.code ;
FROM Numbers LEFT OUTER JOIN Tariffs ON Numbers.number = trim(Tariffs.number) ;
WHERE !empty(Tariffs.number)
This works in pure Foxpro, not in other SQL dialects.
In Foxpro, an expression like this:
longString = shortString
returns .T., when the longString at the left side starts with shortString on the
right side of =
A more complete (but not necessary in Foxpro) would be:
SELECT Numbers.number,
Tariffs.code ;
FROM Numbers LEFT OUTER JOIN Tariffs ON ;
left(Numbers.number, len(trim(Tariffs.number)) = trim(Tariffs.number) ;
WHERE !empty(Tariffs.number)
LEFT OUTER JOIN returns .NULL. as
Tariffs.code for every row in Numbers where
there is no matching row in Tariffs.
You will get unexpected results, if there are number entries in TARIFF like
087
0871
since the first entry will also match the telefon numbers that start with 0871
Regards
Bernhard Sander