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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

find char in string

Status
Not open for further replies.

KryptoS

Programmer
Feb 7, 2001
240
BE
Hey,

I have a table with a string field in it with those values:

ez-ha
fa, ra
fa
ka, dk
ka, fkr
ka-za
...

I want to creat a selecht where I only get the letters before the ',' ... and if there is no ',' in the string I need the whole string.
So I have to come to this:
ez-ha
fa
fa
ka
ka
ka-za
...

I just can't find out how I can get the position of the ',' in the string with sql :s

The One And Only KryptoS
 
select case when locate(',',col) = 0
then col
else left(col,locate(',',col)-1) end

rudy
SQL Consulting
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top