On 2006-03-18, at 00:59, Yani Copas wrote:
Is there a quick and dirty way to update such that I can only affect the portionof a string (varchar column) that matches a regexp? (e.g. replace all '%20' with ' ' leaving the rest untouched?)
You know that proverb - "For a man in possession of a hammer, everything looks like a nail". Don't do that. MySQL is *really slow* with Regular Expressions. It will be much easier to SELECT all records you want to change, storing their IDs in a list (or array) construct, then tell your favourite script program to construct an REPLACE query out of these chosen few, after it does whatever you want it to do with the records' data. Tcl is well known for excellent Regular Expression engine, but most of popular script languages (like PHP) have decent ones. You might write a stored procedure when it will work properly in production quality versions of MySQL (in script language) to make your database more isolated from presentation layer of your software system. For now, simply use script language for processing data and MySQL for storing and protecting it. If anyone would like to correct my assumptions toward current state of stored procedures in arbitrary language feature, feel
free to correct us! -- Sanity check! Warning! This message was written under influence of drugs, music, women, air, water, fire, Earth, antimatter and and love. All the characters included are fictious to the point and any connections toward real persons are random refuse charm
smime.p7s
Description: S/MIME cryptographic signature