Here is the sql statement :
UPDATE
(SELECT table1.nbqe as OLD_nbqe, table2.nbqe as NEW_nbqe,
table1.adr1 as OLD_adr1, table2.adr1 as NEW_adr1
table1.adr3 as OLD_adr3, table2.adr2 as NEW_adr3
FROM table1
INNER JOIN table2
ON table1.cg= table2.cg AND table1.ce = table2.ce
) t
SET t.OLD_nbqe = t.NEW_nbqe, t.OLD_adr1 = t.NEW_adr1, t.OLD_adr3 = t.NEW_adr3
This occurs a 01779 error : cannot modify a column which maps to a non key-preserved table
How can I modify the sql statement to realize the operation ?
Ty
Note : this question is no duplicate
table1 columns :
nbqe
adr1
adr2
adr3
cg
ce
table2 column :
nbqe
adr1
adr2
cg
ce
in table 2 , cg + ce is a single key
in table 1 you can have several records with the same couple (cg, ce).
no constraints of these tables, not even primary keys or anything.
I will ask it differently. The sql statement is probably wrong.
The select inside the update returns the 8 rows of table 1 that should be modified with the value of table2 that can be found in the t table.
How do I update the 8 row sof table1 with the corresponding values of table2 using the table t : is that possible or should I write a big sql statement repeating all the time the same sub query which seems to very strange and not clean.