namalfernandolk
namalfernandolk

Reputation: 9134

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.

Upvotes: 30

Views: 26530

Answers (1)

Quassnoi
Quassnoi

Reputation: 425683

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

Upvotes: 57

Related Questions