Reputation: 11
I need to take a postal code looking like:
S7Y 6H5
that's in a table and display it as
S7Y & 6H5
I can't find a command that splits the string in sql.
Upvotes: 1
Views: 101
Reputation: 37243
you can use INSERT
INSERT(str,pos,len,newstr)
SELECT INSERT('S7Y 6H5', 4, 0, ' & ');
http://dev.mysql.com/doc/refman/5.5/en/string-functions.html#function_insert
Upvotes: 1
Reputation: 18312
MySQL doesn't include a split function, but it does include a replace. You could use:
SELECT REPLACE('S7Y 6HS', ' ', ' & ')
The greater question for me, though, is why don't you do that in your application code?
Upvotes: 3