like keyword pattern matching on postcodes

  • Hi,

    I have a some data that contains postcodes

    eg:

    hr1

    hr2

    hr3

    ...

    hr45

    how would I select a range of these using a like keyword:

    e.g. col is like 'hr[1-3]'

    would give me hr1 hr2 hr3

    but how do i get hr9 hr10 hr 11 ??

    i can't do col is like 'hr[9-11]'

  • You cannot do this with just a simple LIKE, as that does a character by character comparison. If the codes never contain data after the numbers, perhaps something like this would be easier:

    
    
    WHERE Col LIKE 'hr%' AND SUBSTRING(Col,3,2) BETWEEN 9 AND 11

    --Jonathan



    --Jonathan

  • Thanks for you help.

    But at the moment i'm not able to change the like statment (only the parameters past to it) so it doesn't look like it is possible until a new release

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply