MySQL Forums
Forum List  »  Portuguese

ATUALIZAÇÃO ENTRE TABELAS (Tipo Procv do excel)
Posted by: Flavio Santos flaviobdsti
Date: January 13, 2021 10:20AM

Olá pessoal! Alguém pode me orientar sobre como devo fazer para resolver a questão abaixo?

PROBLEMA: veja que na 'tabela_1' no campo 'nome' os valores se repetem. Eu preciso preencher o campo 'status' desta tabela com o valor 'OK' sempre que o campo nome da tabela_1 for igual ao campo 'nome' da tabela_2.



TABELA_1

ID | NOME | STATUS
1 | A |
2 | B |
3 | A |
4 | D |
5 | A |


TABELA_2

ID | NOME |
1 | A |
2 | Y |
3 | D |


Eu tentei com esse script abaixo, porém ele não atualizou todos os valores que se repetem, podem me ajudar? Desde ja agradeço!

---------------------------------------------
update tabela_1 as t1 set status = 'OK'
where t1.nome
IN (select nome from tabela_2);
---------------------------------------------

Options: ReplyQuote


Subject
Views
Written By
Posted
ATUALIZAÇÃO ENTRE TABELAS (Tipo Procv do excel)
599
January 13, 2021 10:20AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.