Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

MySQL question


Guest

Recommended Posts

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

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?

 

 

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

sure, you could do:

 

update table set fieldx = 'Buy this CD today and get a free lobotomy' where fieldx = 'Buy this CD'

 

The string in each field is different so I can't do a straight WHERE query.

Link to comment
Share on other sites

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.

 

 

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...