You are here:  » Amending a table using sql/phpmyadmin

Support Forum



Amending a table using sql/phpmyadmin

Submitted by paddyman on Fri, 2010-09-03 10:52 in

Hi David,

Doing some product mapping at the moment and just wondering if there is any quick way of adding the equal character "=" before each line in my alternates field of the productsmap table.

So in each row I would of alternates I might have a number of products as follows

=2010 A
=2010 B
=2010 C

This would save me having to manually enter the = character.

Hope this makes sense !!

Adrian

Submitted by support on Fri, 2010-09-03 11:08

Hi Adrian,

I strongly recommend that you backup your productsmap table before attempting this, but have a go with:

UPDATE productsmap SET alternates = CONCAT('=',REPLACE(alternates,0x0A,CONCAT(0x0A,'=')));

Cheers,
David.
--
PriceTapestry.com

Submitted by paddyman on Fri, 2010-09-03 11:35

Excellent, worked great :)

Do you know of a similar command to remove the = character or to simply do a search and replace ?

Thanks

Adrian

Submitted by support on Fri, 2010-09-03 16:18

Hi Adrian,

The MySQL REPLACE() syntax can be used for more straight forward global modifications, e.g. to remove all "=" from the alternates...

UPDATE productsmap SET alternates = REPLACE(alternates,'=','');

Cheers,
David.
--
PriceTapestry.com

Submitted by paddyman on Sun, 2010-09-05 09:03

Thanks David