Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Substring extraction

Status
Not open for further replies.

posiedon

Programmer
Mar 22, 2002
8
0
0
GB
Hi

I wish to select from a column, the names of customers. These names are in the format: "customername-location".

how can i ignore everything after the "-" character and just select the customername section?

i have looked at the substr() function, but as the customername is variable in length, i cannot split the data by a constant number of characters.

Thanks in advance

Stephen
 
Always helps to include what DBMS you're using. So, which is it?
 
I have managed to find a compound statement to perform what i am looking for:

select SUBSTR( CUSTOMER_SITES.NAME, 0, ((INSTR(CUSTOMER_SITES.NAME, '-', 1,1)) -1))

Is there a simpler way of performing this select??
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top