Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello!
After loading two tables I want to append into second table rows with keys of first table that not exist in second table.
How can I do this using EXISTS Function?
Please see small example attached.
Try this Script:
t1:
LOAD id as idCheck,
b;
LOAD * INLINE [
id, b
1, b1
2, b2
3, b3
4, b4
5, b5
];
t2: // Contains less rows than t1
LOAD * INLINE [
id, c
1, c1
2, c2
3, c3
];
// Trying to upload into t2 the absent keys from t1
Concatenate(t2)
LOAD
idCheck as id,
b as c
Resident t1
Where not Exists (id, idCheck);
DROP Table t1;
Output will look like this:
I understood the idea. But t1 and t2 have to be linked by 'id'.
Are you trying to merge them into one table or keep two tables?
1st Case:
T2 with T1 and T2 Data
or
2nd Case:
T1 with T1 Data and
T2 with T1 and T2 Data
which one are you trying to achieve?
Best,
Sunny
t1:
LOAD id as idCheck,
b;
LOAD * INLINE [
id, b
1, b1
2, b2
3, b3
4, b4
5, b5
];
t2: // Contains less rows than t1
LOAD * INLINE [
id, c
1, c1
2, c2
3, c3
];
// Trying to upload into t2 the absent keys from t1
Concatenate(t2)
LOAD
idCheck as id,
b as c
Resident t1
Where not Exists (id, idCheck);
t:
NoConcatenate
load idCheck as id, b
resident t1;
DROP Table t1;
RENAME Table t to t1;