update replace() regex

update replace() regex

am 08.07.2010 21:37:56 von nixofortune

Hi ALL,
I wonder if possible at all to use replace() together with regex in
update statement.
I want to be able to update a field of string values and replace a
'dash' character with a space in the string.
Something like:
UPDATE table SET column = replace(column, regex '%-%', ' ') where id = xxx;

Obviously, regex doesn't work inside of replace().
Any suggestions, guys?
Thanks,
Igor

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2@m.gmane.org

Re: update replace() regex

am 08.07.2010 22:58:17 von Dan Nelson

In the last episode (Jul 08), Egor Shevtsov said:
> I wonder if possible at all to use replace() together with regex in update
> statement. I want to be able to update a field of string values and
> replace a 'dash' character with a space in the string. Something like:
> UPDATE table SET column = replace(column, regex '%-%', ' ') where id = xxx;

You don't need a regex for that. REPLACE(column, '-', ' ') should do what
you want.

--
Dan Nelson
dnelson@allantgroup.com

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2@m.gmane.org

Re: update replace() regex

am 08.07.2010 23:01:47 von nixofortune

--------------050108080603060108060101
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Thanks Dan,
I tested it just now. It works perfectly.

Dan Nelson wrote:
> In the last episode (Jul 08), Egor Shevtsov said:
>
>> I wonder if possible at all to use replace() together with regex in update
>> statement. I want to be able to update a field of string values and
>> replace a 'dash' character with a space in the string. Something like:
>> UPDATE table SET column = replace(column, regex '%-%', ' ') where id = xxx;
>>
>
> You don't need a regex for that. REPLACE(column, '-', ' ') should do what
> you want.
>
>

--------------050108080603060108060101--