update starting a select

Dúvidas, dicas e truques de SQL, Select, Update, Delete, cláusulas, operações com joins, Funções em SQLs, etc
Post Reply
carlos12
Rank: Analista Pleno
Rank: Analista Pleno
Posts: 123
Joined: Wed, 24 Oct 2007 4:31 pm
Location: rio

Personal I need to make an update on a table but it has to be from a select ... type I have a select with joins and etc, then it returns about 3545 records need to make an update in this table, how?
Tupi
Rank: Programador Sênior
Rank: Programador Sênior
Posts: 57
Joined: Wed, 26 Mar 2008 12:34 pm
Location: Porto Alegre

Friend I do not know if I understood your doubt more if not this in the tries again: lol:

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)
User avatar
dr_gori
Moderador
Moderador
Posts: 5024
Joined: Mon, 03 May 2004 3:08 pm
Location: Portland, OR USA
Contact:
Thomas F. G

Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered

You have to give more information about how this update is.
A "basic" form of doing this is like this:

Select all

UPDATE tabela y 
SET campo = (select campo 
             FROM xxxxxx z  
             WHERE z.chave = y.chave) 
WHERE  .... ( retorna as 3545 linhas)
Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 18 guests