Archive for the ‘MySQL’ Category

website development in ahmedabad

website development in ahmedabad


Appending data to a MySQL database field that already has data in it

Need to “add” data to a field that already contains data without erasing whats currently there. For example if the field contains HTML, I need to add additional HTML to the field. Is there a SQL call that will do this or do I need to call the data in that field, concatenate the new data to the existing data, and reload it into the database?

Yes you can use the following query to append data to database field.

UPDATE Table SET Field=CONCAT(Field,'your extra html');
and you can also do it with specific where condition
UPDATE myTable SET html=concat(html,'<b>More HTML</b>') WHERE id='10'