wright67uk Posted May 26, 2012 Share Posted May 26, 2012 how can I append a text string to each row in a column? I have a database with several columns; ID, name, product, product_id, description etc. the description column is made of BLOBS. I need to add the same string of text to the end of each description in my table. " </p> </p> This tree has been recently potted at the end of bare root season. " Is this possible to do using 1 sql query? I only have 20 or so products in this table so I could do this manually 20 times, but I thought it would be useful to know, especially if I have to add text to a table someday with 500 products in. Link to comment https://forums.phpfreaks.com/topic/263176-how-can-i-append-a-text-string-to-each-row-in-a-column/ Share on other sites More sharing options...
Barand Posted May 26, 2012 Share Posted May 26, 2012 UPDATE mytable SET description = CONCAT(description, ' </p> </p> This tree has been recently potted at the end of bare root season. '); Link to comment https://forums.phpfreaks.com/topic/263176-how-can-i-append-a-text-string-to-each-row-in-a-column/#findComment-1348849 Share on other sites More sharing options...
wright67uk Posted May 27, 2012 Author Share Posted May 27, 2012 Perfect, Thankyou! For future reference , is this possible? eg. if later in the year I want to change " </p> </p> This tree has been recently potted at the end of bare root season. " to " </p> </p> This tree is a bare root product. " how can i search for the mentioned text string and change only that text string without effecting any text before it? Link to comment https://forums.phpfreaks.com/topic/263176-how-can-i-append-a-text-string-to-each-row-in-a-column/#findComment-1348886 Share on other sites More sharing options...
Barand Posted May 27, 2012 Share Posted May 27, 2012 MySQL has a REPLACE function Link to comment https://forums.phpfreaks.com/topic/263176-how-can-i-append-a-text-string-to-each-row-in-a-column/#findComment-1348915 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.