How can I append a string to an existing field in MySQL?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
To append text to an existing string column in MySQL, use UPDATE together with CONCAT. The important part is that you reference the current column value and join the new text onto it, rather than replacing the whole field. You also need to think about NULL behavior, because CONCAT returns NULL if any argument is NULL.
Basic Append with CONCAT
The normal pattern looks like this:
If bio currently contains Developer, the result becomes Developer - verified. This works because CONCAT joins the old value with the appended string.
Append to Multiple Rows Safely
You can use the same idea for any subset of rows:
This appends the suffix only to rows that match the WHERE clause. As usual with UPDATE, the WHERE clause matters a lot. Forgetting it can append the same text to every row in the table.
Handle NULL Correctly
This is the most common mistake. In MySQL, CONCAT(NULL, 'abc') returns NULL. So if the existing field may be NULL, wrap it with COALESCE or IFNULL.
Now a NULL bio becomes just - verified instead of staying NULL. If you want better formatting, add conditional logic so the separator appears only when the original field has content.
That keeps the result cleaner.
Append a Prefix or Surrounding Text
CONCAT is not limited to appending at the end. You can build the final string in any order you need.
Or surround the value:
The main design rule is to build the full target value explicitly.
Consider Idempotency
If the update may be run more than once, appending blindly can duplicate the suffix repeatedly. That is a data-quality problem, not a SQL syntax problem.
For example, this can run safely only once:
If the same statement runs twice, you may get ... | exported | exported. To prevent that, add a condition:
This matters in scripts, migrations, and batch jobs that may be retried.
Know When String Appending Is the Wrong Design
Appending text is fine for notes, audit-style free text, or temporary labels. It is a bad substitute for real structured data. If you keep adding machine-readable state into one growing string column, querying and maintaining that data becomes difficult. In many cases, a separate column or table is the better model.
Common Pitfalls
- Forgetting to reference the original column value in the
UPDATE. - Ignoring
NULLbehavior and gettingNULLback fromCONCAT. - Omitting the
WHEREclause and updating every row. - Appending the same marker multiple times in retryable jobs.
- Using string concatenation where structured schema changes would be cleaner.
Summary
- Append text in MySQL with
UPDATE ... SET column = CONCAT(column, 'suffix'). - Use
COALESCEorIFNULLif the existing column may beNULL. - Be careful with separators so empty values do not produce awkward output.
- Add conditions if the update might run more than once.
- Use string appending for text fields, not as a replacement for proper data modeling.

