如何构建匹配所有英国城镇的Sql查询

时间:2014-06-19 20:59:59

标签: sql location geocode

我想查询所有英国全球数据库成员。

我可以使用Ansi SQL并具有正则表达式支持。

我不能修改,因此我无法在其中创建表格并且它太大而无法进行地理编码

 SELECT 
   login,
   location
 FROM GLOBALDATA
 where 
 (
  lower( location) like '%united kingdom%' or
  (lower( location) like '%england%' 
    and lower( location) not like '%new england%'
  ) 
  or
  (lower( location) like '%london%' 
    and lower( location) not like 'london%on' 
    and lower( location) not like '%ontario%'
    and lower( location) not like '%canada%'
  )
  or
  (lower( location) like '%uk%' 
    and lower( location) not like '%breukelen%'
    and lower( location) not like '%takatsuki%'
    and lower( location) not like '%phuket%'
    and lower( location) not like '%fukushima%'
    and lower( location) not like '%ukarine%'
    and lower( location) not like '%ukrain%'
    ...
    and lower( location) not like '%ortenaukreis%'
    and lower( location) not like '%takarazuka%'
    and lower( location) not like '%mukwonago%'
    and lower( location) not like '%ukrane%'
    and lower( location) not like '%sukabumi%'
    and lower( location) not like '%milwaukee%'
  )
  or
  lower( location) like '%sussex%'
  or
  (lower( location) like '%bristol%'
  -- ignore bristol, VA
  and lower( location) not like '%va%'
  )

  -- uk towns
  --
  -- http://www.dangibbs.co.uk/journal/free-uk-postcode-towns-counties-database
  --
  or lower( location) like 'abbots langley%'
  or lower( location) like 'abbotsham%'
  or lower( location) like 'abenbury%'
  or lower( location) like 'aberaeron%'
  or lower( location) like 'abercarn%'
  ....
  or lower( location) like 'yealmpton%'
  or lower( location) like 'yeovil%'
  or lower( location) like 'ystrad%'
  or lower( location) like 'ystradgynlais%'
)
-- AND we DONT want
-- http://statetable.com/
--
and not 
-- state codes
(
   location like '%, AA'
  or  location  like '%, AE'
  or  location  like '%, AP'
  ...
  or  location  like '%, VT'
  or  location  like '%, WA'
  or  location  like '%, WI'
  or  location  like '%, WV'
  or  location  like '%, WY'

  -- also state names
  or  location like '%Alabama'
  or  location like '%Alaska'
  or  location like '%Arizona'
  ...
  or  location like '%Kingman Reef'
  or  location like '%Navassa Island'
  or  location like '%Serranilla Bank'
  or  location like '%Bajo Nuevo Bank'
)

我的问题是,是否有人知道是否有人为其他国家/地区提供了比此更通用的内容?

我找不到任何东西..

0 个答案:

没有答案