Blog

Newest Post
Blog Archives
Blog Categories

Portfolio

3D Models
Banners
Brochures
Business Cards
Custom Programming
Environments
Flash Projects
Game Design
Image Altering
Web Design

About

Resume
Recommendation Letters

Contact

November 4, 2009

MySQL, UPDATE data into a database using CONCAT()

Filed under: The Coding World — admin @ 2:46 pm

To insert data into a MySQL database while preserving the already existing data, you will just concatenate your new data to the end of your existing data.

Below is an example of how to do it using the column “changelog” which is used to keep track of changes made to the row/record.

View Code MYSQL
UPDATE table1 SET changelog=CONCAT(changelog,"new data") WHERE id='idnumber'

If you would like the data that you are entering to appear at the beginning of the existing data, simply flip the concatenation, example:

View Code MYSQL
UPDATE table1 SET changelog=CONCAT("new data",changelog) WHERE id='idnumber'

Leave a Reply

© - Digital Epiphany Designs, Online Portfolio for Web Design, Custom Programming, Grapic Design and Game Design.