Я использую такой запрос для автокомплита:
SELECT geonames.geonameid as id, geonames.name, countries.name as country, regions.name as region
FROM geonames
JOIN alternatives ON (alternatives.geonameid = geonames.geonameid)
WHERE alternatives.alternateName LIKE 'моск%' and fclass='P'
GROUP BY geonames.geonameid
ORDER BY geonames.population desc, geonames.name=geo_alternatives.alternateName desc
LIMIT 10
И такой запрос для получения идентификатора города по данным из maxmind:
SELECT geo_cities.geonameid as id
FROM geonames
JOIN countries ON (geonames.country = countries.iso_alpha2)
JOIN regions ON (concat(geonames.country, '.', geonames.admin1) = regions.code)
JOIN alternatives ON (alternatives.geonameid = geonames.geonameid)
WHERE geonames.country = :country AND geo_alternatives.alternateName = :city and fclass='P'
GROUP BY geonames.geonameid
ORDER BY geonames.population desc, geo_cities.name=geo_alternatives.alternateName desc
LIMIT 1