2 Replies Latest reply: Sep 4, 2017 10:06 AM by Jordi Raya RSS

    Update field of a resident table depending on values of another table

    Jordi Raya

      Hi,

       

      Due to my inexperience I don't know how to solve this apparently simple problem.

      I've loaded a table with a id, some data and a flag 0/1, with default value 0


      Employees1:

      LOAD id,

        ...

        0 AS flag

      FROM [..];

       

      idflag
      A0
      B0
      C0
      D0

       

       

      Also, I've another table 'Employees2' with the same ids as 'Employees1'

      Employees2:

      LOAD id,

        ...

      FROM [..];

       

      id
      A
      C


      The problem is that I need to update the field 'flag' of 'Employees1' in order to set a value of 1 for the records whose ids are present in 'Employees2'. In the example, this is the final outcome desired:

       

      idflag
      A1
      B0
      C1
      D0

       

      I'm considering looping 'Employees1', checking if each id exists in 'Employees2' and updating the flag if it's the case, but I don't konw if this is possible (in special the update part) or if this is the correct approach.

       

      Thanks in advance,