View Single Post
  #6 (permalink)  
Old Feb 21st, 2008, 12:32
welshstew's Avatar
welshstew welshstew is offline
Lead Administrator

SuperMember
Join Date: May 2007
Location: inside the outside
Posts: 1,388
Blog Entries: 13
Thanks: 1
Thanked 16 Times in 14 Posts
Re: Query postcode issue?

Quote:
Originally Posted by puzz View Post
You can try something like this:

select substring(postcode,1,if(instr(postcode," ")=0,length(postcode),instr(postcode," "))) from my_table;

It will return part of your string from the first character to the first space...
what if they don't put a space in?
__________________
WelshStew
Lead Administrator

tierney rides tboard - uk site | xtreme wales - extreme clothing
If you think I've helped, click the "Thanks"
webforumz - facebook | LinkedIn
Reply With Quote