Connecting Tech Pros Worldwide Help | Site Map

how get the value from the string

ddtpmyra's Avatar
Familiar Sight
 
Join Date: Jun 2008
Location: CA
Posts: 222
#1: Oct 1 '09
Hi,

I wonder how can you select the numbers but it will cut after the space.

Here's the example string
Quote:
12345 - Apple
I know theres tricky how to do it that like instr in access that i have to combined with select right(' ',5) but the string numbers varies but how can i tell on my query it should stop selecting when it reaches the space in between the dash?
appreciate your help
Atli's Avatar
Moderator
 
Join Date: Nov 2006
Location: Iceland
Posts: 3,741
#2: Oct 1 '09

re: how get the value from the string


Hey.

Try the SUBSTRING_INDEX function.

I have to ask tho, why do you need to do this?
This sort of thing should be done by whichever front-end software is using your database.

Unless you are actually storing those strings inside your database, in which case you might want to reconsider your table design.
Reply