Updating by Concatenating Columns in Postgresql

I need to set the hotelcode by concatenating it with the vendorcitycode (separated by an underscore) as follows.

update schema.table_name set
       hotelcode = hotelcode+"_"+vendorcitycode)
 where vendorid = 'INV27' and vendorcitycode = 'LON'

Note : hotelcode and vendorcitycode are two columns of type character varying(100). I use PostgreSQL 8.0.

1

1 Answer

UPDATE   table_name
SET      hotelcode = hotelcode || '_' || vendorcitycode
WHERE    (vendorid, vendorcitycode) = ('INV27', 'LON')
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Sophia Al-Mansoor

Sophia Al-Mansoor

Global Business & E-Commerce Reporter

Sophia analyzes international trade, startup ecosystems, retail transformation, and supply chain logistics for modern digital publications.

Share this article
Twitter Facebook Pinterest