SQLTeam.com | Weblogs | Forums




what is the wildcard for the following. I need to search for postcode that start with a single letter for instance "L"so when I use the % wildcard it picks up any postcodes that start with an "L" followed by another alpha character

below is a quick example of the postcodes so I want postcodes 1 and 2 but using the % wildcard get all of them

  1. L25 78A
  2. L23 87J
  3. LT1 89H
  4. LS9 28L

please advise?



This is probably not the best way...

WHERE postcodes like 'L%' AND PATINDEX('%L[0-9]%) = 1

You cannot use the PATINDEX alone as it would also get something like LL1...


You could combine the conditions using

WHERE postcodes like 'L[0-9]%'


thanks for these work a treat!! :smile: