DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Scottish Postcode Match

04.18.2009
| 3760 views |
  • submit to reddit
        // Matches Scottish Postcodes
// http://en.wikipedia.org/wiki/List_of_postcode_areas_in_the_United_Kingdom

SELECT * FROM table 
WHERE ( 
   postcode LIKE 'KW%' OR 
   postcode LIKE 'IV%' OR 
   postcode LIKE 'AB%' OR 
   postcode LIKE 'PH%' OR 
   postcode LIKE 'DD%' OR 
   postcode LIKE 'PA%' OR 
   postcode LIKE 'G[0-9]%' OR 
   postcode LIKE 'FK%' OR 
   postcode LIKE 'KY%' OR 
   postcode LIKE 'HS%' OR 
   postcode LIKE 'EH%' OR 
   postcode LIKE 'ML%' OR 
   postcode LIKE 'KA%' OR 
   postcode LIKE 'DG%' OR 
   postcode LIKE 'TD%' OR 
   postcode LIKE 'ZE%' 
)