update from a select

Dúvidas, dicas e truques de SQL, Select, Update, Delete, cláusulas, operações com joins, Funções em SQLs, etc

Poston Fri, 23 May 2008 7:44 am

People need to do an update on a table but it has to be from a select ... type have a select with joins and etc, then he returns about 3545 records need to do an update on this table, how?
Location: rio

Poston Fri, 23 May 2008 12:24 pm

Friend I don't know if I get it right your doubt more if not for this in try again: lol:
Code: Select all
UPDATE copy_emp
SET department_id = (SELECT department_id
                                 FROM employees
                                 WHERE employee_id = 100)
WHERE job_id        = (SELECT job_id
                                 FROM employees
                                WHERE employee_id = 200)
Location: Porto Alegre

Poston Fri, 23 May 2008 1:23 pm

You have to give more information about this update.
A \"basic\" to do this is like this:
Code: Select all
UPDATE tabela y
SET campo = (select campo
             FROM xxxxxx z
             WHERE z.chave = y.chave)
WHERE  .... ( retorna as 3545 linhas)
Location: Portland, OR USA

Thomas F. G

Você já respondeu a dúvida de alguém hoje?

  • See also
    Last Post

    Return to SQL

    Who is online

    Users browsing this forum: No registered users and 6 guests