Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
xiaojunzai
Contributor III
Contributor III

The load script issues

I have the following two tables,

table1:

abcd
1234
5678
11223344
55667788
1111
2222
3333
4444
5555

table2:

 

ijkl
4321
9876
99887766
55443322
1111
2222
9999
8888
7777

What I want to do is to match the content of table1 with the content of table2. If the content of table2 exists in table1, it is deleted in table1, and if it does not exist, the content of table2 is inserted into table1.

Thanks a lot!

2 Replies
sunny_talwar

So, is there any content which exists in table2 which is also in table1? I don't think so, right? or I might not have understood the issue... can you share the expected output based on the two tables provided?

kaanerisen
Creator III
Creator III

Hi junzai,

You can use AutoNumberHash128 and Exists functions to check if the row occurs in both table.

Script:

Table1:

Load *,AutoNumberHash128(A,B,C,D) as RowKey1 inline [

"A","B","C","D"

1,2,3,4

5,6,7,8

11,22,33,44

55,66,77,88

1,1,1,1

2,2,2,2

3,3,3,3

4,4,4,4

5,5,5,5

];

Table2:

Load *,AutoNumberHash128(I, J, K, L) as RowKey2 inline [

"I","J","K","L"

4,3,2,1

9,8,7,6

99,88,77,66

55,44,33,22

1,1,1,1

2,2,2,2

9,9,9,9

8,8,8,8

7,7,7,7

];

Master:

LOAD A,B,C,D Resident Table1

WHERE NOT Exists(RowKey2,RowKey1);

Concatenate

LOAD I AS A, J AS B, K AS C, L AS D Resident Table2

WHERE NOT Exists(RowKey1,RowKey2);

DROP TABLES Table1,Table2;

Output:

Untitled.png