Try this way is an update with select correlated ( Correlated select )... something like that:
UPDATE PCPSEQPROC_001 PCPSEQPROC
SET
PCPSEQPROC.ID_PCPSEQPROC = (select PCPSEQ.ID_PCPSEQ from
PCPSEQ_001 PCPSEQ where PCPSEQ.PRODUTO = PCPSEQPROC.PRODUTO)
WHERE PCPSEQPROC.ID_PCPSEQPROC IS NULL
If you give ambigous in the subselect, you have more than one key, it is not one to one the relationship of PCPSEQPROC and PCPSEQ_001, in this case, You would need something like the following to recover a single line in the subselect, but be sure that this is what you want!!!
UPDATE PCPSEQPROC_001 PCPSEQPROC
SET
PCPSEQPROC.ID_PCPSEQPROC = (select MIN(PCPSEQ.ID_PCPSEQ) from
PCPSEQ_001 PCPSEQ where PCPSEQ.PRODUTO = PCPSEQPROC.PRODUTO)
WHERE PCPSEQPROC.ID_PCPSEQPROC IS NULL
I don’t have a test bench but that’s about it!
In which database? Mysql? Postgres? MSSQL?
– rray
If Mysql syntax is incorrect, the
SET
comes after theINNER JOIN
– arllondias
gbd is the Firebird
– Rogerio Jung