RE: how to replace this data in a complex field?
In other words, this might work?? UPDATE Table1 SET Inventory = REPLACE(Inventory, '"ACRE_PRC119_ID_29"', '"ACRE_PRC119"'); Note: the extra quotes were deliberate. If it is not always ID_29, then the problem is more difficult. > -Original Message- > From: Johan De Meersman [mailto:vegiv...@tuxera.be] > Sent: Tuesday, July 31, 2012 1:39 AM > To: Incarus Derp > Cc: mysql@lists.mysql.com > Subject: Re: how to replace this data in a complex field? > > > > - Original Message - > > From: "Incarus Derp" > > > > I have a complex field named Inventory in a table named Table1 that > > can be different every time and is not guaranteed to contain what I > > need to replace. > > > > > [["Thing1","Thing4","thing8","thing1","thing942","ACRE_PRC119_ID_29"], > > [["thing1700",2],"datthing4","pizza","water","apples,"beans","coke-a- > c > > > ola","rice","apples","apples","icecream","pizza",["7things",6],"7thing > > s","7things","8things","tophats","tophats","762x39mmRU"]] > > That looks more like a multidimensional array than a table, to me. > > > > > I need to replace ACRE_PRC119_ID_29 with ACRE_PRC119 and I cannot do > > this externally. I have PREG_REPLACE but I'm not sure how I would > > apply this to the database because it only SELECT's as far as I know. > > ...and preg_replace is a PHP function, not a MySQL one. Are you sure > you're on the right list? > > In any case, if you're looking to do this in MySQL, this is the > function you're probably going to be using: > http://dev.mysql.com/doc/refman/5.0/en/string- > functions.html#function_replace > > If you're looking to do those substitutions on an mdarray in PHP, well, > wrong list :-) I'll hint you that you're probably going to have to > write a recursive function, though, if your mdarray has varying depth. > > > -- > Linux Bier Wanderung 2012, now also available in Belgium! > August, 12 to 19, Diksmuide, Belgium - http://lbw2012.tuxera.be > > -- > MySQL General Mailing List > For list archives: http://lists.mysql.com/mysql > To unsubscribe:http://lists.mysql.com/mysql -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql
Re: how to replace this data in a complex field?
- Original Message - > From: "Incarus Derp" > > I have a complex field named Inventory in a table named Table1 that > can be different every time and is not guaranteed to contain what I need to > replace. > > [["Thing1","Thing4","thing8","thing1","thing942","ACRE_PRC119_ID_29"],[["thing1700",2],"datthing4","pizza","water","apples,"beans","coke-a-cola","rice","apples","apples","icecream","pizza",["7things",6],"7things","7things","8things","tophats","tophats","762x39mmRU"]] That looks more like a multidimensional array than a table, to me. > > I need to replace ACRE_PRC119_ID_29 with ACRE_PRC119 and I cannot do > this externally. I have PREG_REPLACE but I'm not sure how I would apply > this to the database because it only SELECT's as far as I know. ...and preg_replace is a PHP function, not a MySQL one. Are you sure you're on the right list? In any case, if you're looking to do this in MySQL, this is the function you're probably going to be using: http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_replace If you're looking to do those substitutions on an mdarray in PHP, well, wrong list :-) I'll hint you that you're probably going to have to write a recursive function, though, if your mdarray has varying depth. -- Linux Bier Wanderung 2012, now also available in Belgium! August, 12 to 19, Diksmuide, Belgium - http://lbw2012.tuxera.be -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql
Re: how to replace this data in a complex field?
On 07/31/2012 09:07 AM, Incarus Derp wrote: I need to replace ACRE_PRC119_ID_29 with ACRE_PRC119 and I cannot do this externally. I have PREG_REPLACE but I'm not sure how I would apply this to the database because it only SELECT's as far as I know. You could CREATE a TABLE from the SELECT. Isn't it? -- RMA. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql
how to replace this data in a complex field?
I have a complex field named Inventory in a table named Table1 that can be different every time and is not guaranteed to contain what I need to replace. [["Thing1","Thing4","thing8","thing1","thing942","ACRE_PRC119_ID_29"],[["thing1700",2],"datthing4","pizza","water","apples,"beans","coke-a-cola","rice","apples","apples","icecream","pizza",["7things",6],"7things","7things","8things","tophats","tophats","762x39mmRU"]] I need to replace ACRE_PRC119_ID_29 with ACRE_PRC119 and I cannot do this externally. I have PREG_REPLACE but I'm not sure how I would apply this to the database because it only SELECT's as far as I know. Any solutions? -Ikarus