Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

296
Vistas
INNER JOIN on UPDATE with WHERE updating every record in Postgres

I'm trying to update a single record and return the email of the owner of the updated record by doing INNER JOIN de ID of the createdby which links to the users table.

Here's the query:

UPDATE requests
SET statusid = 2
FROM requests AS r
INNER JOIN users
ON r.createdby = users.id
WHERE r.id =10
RETURNING r.id, users.email;

But this will update every record instead of using the WHERE.

What am I doing wrong?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

In Postgres, you do not repeat the table being updated in the FROM. So:

UPDATE requests r
    SET statusid = 2
    FROM users u
    WHERE r.createdby = u.id AND r.id =10
RETURNING r.id, u.email;
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda