-2
    UPDATE table1, (select top 1 [ID],chef,formateur,techni from table1 order by Num desc) 
AS x SET table2.ID = x.[ID], table2.Nom = x.[chef], table2.Nom = x.[formateur],
table2.Nom = x.[techni]
WHERE table2.mission="chef" and table2.mission="Formateur" and table2.mission="techni" ;

returns
table2                                            table 1
 ID | mission      |Nom|                ID |chef|Formateur|techni|   
 --------------------------------           ----------------------------
  1 |  chef        |   |                 1 |nom1|    nom2 | nom3|  
  2 |  Formateur   |   |               **Result**  
  3 |  techni      |   |                   ID | mission   | Nom|
                                         --------------------------  
                                            1 |  chef     | nom1|      
                                            2 |  Formateur| nom2|
                                            3 |  techni   | nom3|  
  1. I want to assign the name of table1 in table 2. Please i need your help :)

1 Answers1

0

Data structure does not make sense. Table2 has only 3 records?

Your attempted example is updating Table1 when it appears you really want to update Table2. Why do you want to pull from just last record of Table1?

But try:

UPDATE Table2, 
(SELECT TOP 1 Table1.ID, Table1.chef, Table1.formateur, Table1.techni
FROM Table1 ORDER BY Table1.ID DESC) AS Q 
SET Table2.nom = Switch([mission]="chef",[chef],[mission]="formateur",[formateur],[mission]="techni",[techni]);
June7
  • 19,874
  • 8
  • 24
  • 34