How to make a "scan" using SQL?

Asked

Viewed 1,049 times

0

I have the following structure in my database:

  • Table tgffin with the columns: CODNAT, AD_CODNAT_OLD
  • Table tgfnat with the columns: CODNAT, AD_NAT_OLD

I want to reclaim the value of tgfnat.CODNAT when tgfnat.AD_NAT_OLD = tgffin.AD_CODNAT_OLD and subsequently update tgffin.CODNAT using the value recovered from the previous query.

How can I do this using a single SQL statement?

1 answer

2

Resolve with a simple update:

UPDATE tgffin, tgfnat
 SET tgffin.CODNAT = tgfnat.CODNAT
 WHERE tgfnat.AD_NAT_OLD = tgffin.AD_CODNAT_OLD;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.