Guest Posted April 16, 2005 Share Posted April 16, 2005 I want to add a string to every record in the products_description column of the products_description table. existing string = "Buy this CD" new string = "Buy this CD today and get a free lobotomy" Is there a simple way to do this using phpmyadmin and UPDATE? Link to comment Share on other sites More sharing options...
boxtel Posted April 16, 2005 Share Posted April 16, 2005 I want to add a string to every record in the products_description column of the products_description table. existing string = "Buy this CD" new string = "Buy this CD today and get a free lobotomy" Is there a simple way to do this using phpmyadmin and UPDATE? <{POST_SNAPBACK}> sure, you could do: update table set fieldx = 'Buy this CD today and get a free lobotomy' where fieldx = 'Buy this CD' Treasurer MFC Link to comment Share on other sites More sharing options...
Guest Posted April 16, 2005 Share Posted April 16, 2005 sure, you could do: update table set fieldx = 'Buy this CD today and get a free lobotomy' where fieldx = 'Buy this CD' <{POST_SNAPBACK}> The string in each field is different so I can't do a straight WHERE query. Link to comment Share on other sites More sharing options...
FalseDawn Posted April 16, 2005 Share Posted April 16, 2005 You are ambiguous in your requirement then. Either the string is "Buy this CD" or it isn't. Please elaborate if you want a solution. Link to comment Share on other sites More sharing options...
Guest Posted April 16, 2005 Share Posted April 16, 2005 You are ambiguous in your requirement then.Either the string is "Buy this CD" or it isn't. Please elaborate if you want a solution. <{POST_SNAPBACK}> Aye, OK. The existing string in products_description is a description of whichever CD is being described. I want to add at the bottom of every product listing description, a wee bit of sales blurb such as "Buy this or we'll kick your granny". So, I can use a text editor, but with 7,500 items, I'm not 200% confident that a global search and insert is the answer. I'd like to be able to do an UPDATE products_listing and keep the current string but add the "Buy this or we'll kick your granny" string to it. Any ideas? Link to comment Share on other sites More sharing options...
FalseDawn Posted April 16, 2005 Share Posted April 16, 2005 UPDATE products_description SET products_description=CONCAT(products_description, '<br><br>your new text'); you can change the <br><br> to whatever html you like - eg add <strong><center> to make it bold and centered - depends. Don't forget the closing tags as well after "your new text" if you use tags that require closing, like </strong> and </center> Before you do a global update like this - please test it first on a single product, eg: UPDATE products_description SET products_description=CONCAT(products_description, '<br><br>your new text') WHERE products_id=XXX where XXX is the ID of your test product. It's a lot easier to add text to fields using SQL than it is to strip it if you mess up. Link to comment Share on other sites More sharing options...
Guest Posted April 16, 2005 Share Posted April 16, 2005 :thumbsup: :thumbsup: Thanks .... that gets added to my list of incredibly useful commands Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.