No responses, but I think I've pretty much reverse-engineered the code:
"A" is an Abbreviation
"P" is the sole Preferred English name of a place whose local language is not English
"Q" is the preferred name of a place in any other language
"V" is a Variant name in any language
A WOEID can only have one "P" alias (total) and one "Q" (per language), but unlimited A and V aliases.
Did I get it right? :bselect a.woeid, a.name, p.place_type from #{ALIASES} as a, #{PLACES} as p where a.woeid=p.woeid and a.name_type='P' and a.woeid in (select woeid from #{PLACES} where country_code='#{CODE}')