Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

170
Visualizações
updating column with value from another column in postgres table

I have a postgres table which has 2 columns

username and email I have hundreds of rows in the table such as

username | email
username1 | test@abc.com
username2 | test@abc.com
username3 | test@abc.com
username4 | test@abc.com

The way this was setup all emails are the same, and now I need to make them unique. I am trying to update the email column to be like this

username | email
username1 | username1_test@abc.com
username2 | username2_test@abc.com
username3 | username3_test@abc.com
username4 | username4_test@abc.com

basically copy over the value from the username column and add it to the email column. I tried using the coalesce function but that will replace the value completely and not update it.

Please can you help me understand how to achieve this.

Thanks

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

An update with basic concatenation should work here:

UPDATE yourTable
SET email = username || '_' || email;
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda