View Single Post
  #1 (permalink)  
Old Feb 21st, 2008, 11:25
meth8200 meth8200 is offline
Junior Member
Join Date: Feb 2008
Location: UK
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
[SOLVED] Query postcode issue?

Hi Everyone,

Basically i've got a postcode query problem, i have a column with postcodes like:

abc 123
abcd 123
ab 123

What im trying to do is query only the first set on digits without the 123.
So my output should be:

abc
abcd
ab

Ive used the following technique:

SELECT TRIM(SUBSTRING(dbTest.postCode,1,4)) AS shortPostCode

FROM dbTest

This is not accurate as it chucks out:

abc
abcd
ab 1 <-?

Because im using a substring 1,4 ab 1 happens.

Any solutions please?? any suggestions would be helpful!

Thanks

Reply With Quote