List:General Discussion« Previous MessageNext Message »
From:Rick James Date:August 1 2012 9:18pm
Subject:RE: how to replace this data in a complex field?
View as plain text  
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:vegivamp@stripped]
> Sent: Tuesday, July 31, 2012 1:39 AM
> To: Incarus Derp
> Cc: mysql@stripped
> Subject: Re: how to replace this data in a complex field?
> 
> 
> 
> ----- Original Message -----
> > From: "Incarus Derp" <icarusderp@stripped>
> >
> > 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

Thread
how to replace this data in a complex field?Incarus Derp31 Jul
  • Re: how to replace this data in a complex field?Mihamina Rakotomandimby31 Jul
  • Re: how to replace this data in a complex field?Johan De Meersman31 Jul
    • RE: how to replace this data in a complex field?Rick James1 Aug