Hi Lars,

Lars Schwarz wrote:
hi all, is there any shorthand to extract the string part of a varchar field
only?
like when having german street addresses (e.g. foostreet 23) in a varchar
field
and i want to select the non-numeric part of it (foostreet) only?

I can't think of a way to do this in MySQL. In MS SQL Server there's a PATINDEX function I used for similar tasks, but I don't think there's anything like that in MySQL.

You could simulate it with an incredibly ugly hack: make a user function that returns the first occurrence of a digit. You might find the LEAST, COALESCE, NULLIF, and LOCATE functions helpful for this. But it will not be pleasant.

I wouldn't be surprised if there's a really nifty way to do it with a table of integers and a cross join against every substring with a MIN(), but I'd be surprised if it's efficient.

I think you're best off doing it in client code with a regular expression.

Baron

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to