How to Append Text in PostgreSQL

How to Append Text in PostgreSQL

July 18, 2025

Used CoPilot, then verified that it was correct. In PostgreSQL, you can append text to a string using the concatenation operator ||.

Example:

SELECT 'Hello' || ' ' || 'World' AS result;

This will return:

 result  
---------
 Hello World

Appending to a column value:

If you want to append text to a value in a column, you can do something like:

UPDATE your_table
SET your_column = your_column || ' appended text'
WHERE some_condition;

Let me know if you want to append conditionally, or based on values from another column!

I did the following:

raw_test_data> update sql_reports.emails
                  set emails = emails || ';person@example.com'
                     ,comment = 'Added person to the group.' 
                where name in ('group1','group2','group3');   

This enabled me to add this person’s email address to multiple email groups.