Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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 [..];
id | flag |
---|---|
A | 0 |
B | 0 |
C | 0 |
D | 0 |
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:
id | flag |
---|---|
A | 1 |
B | 0 |
C | 1 |
D | 0 |
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,
Hi,
May be like this?
Table1:
LOAD*Inline
[id
A
B
C
D
];
Left Join
Table2:
LOAD*Inline
[id, Flag
A, 1
C, 1
];
In table NULL value change to zero.
Result
Hi,
May be like this?
Table1:
LOAD*Inline
[id
A
B
C
D
];
Left Join
Table2:
LOAD*Inline
[id, Flag
A, 1
C, 1
];
In table NULL value change to zero.
Result
Yes, it's correct, it can be done easily with a left join. Tanks!
Hi,
This solution will work perfectly when there is no data in Table 1, however can you please tell how will you update if there exist values for different columns and you have to update more than one columns.