Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
simotrab
Creator III
Creator III

Load from different sources and merging the results

Hi Qlik Experts!

I have a question about load datas from difference sources.

Let's explain with an example:

first, I have this table from DataBase 1:

Table1:

LOAD

*

;

SQL SELECT

Person

FROM DataBase1;

The result is:

Person
p1
p2
p3
p4

Now, I should do the same thing with DataBase2:

Table2:

LOAD

*

;

SQL SELECT

Person

FROM DataBase2;

The result is:

Person
p1
p2
p5

I decide to use both the script in the same time (and I need one table), so the result is clearly this:

Table1_2:

LOAD

*

;

SQL SELECT

Person

FROM DataBase1;

Table1_2:

LOAD

*

;

SQL SELECT

Person

FROM DataBase1;

Person
p1
p2
p3
p4
p1
p2
p5

Now the question: could I do a " distinct" of the last table (and how)? In other words, could I reach (and how) this result?

Person
p1
p2
p3
p4
p5

Thanks a lot for your time!

1 Solution

Accepted Solutions
Not applicable

you could look into the Exists function: The exists issue

(that article mentions the drawback with the Exists function - but also gives a usage example)

Otherwise, you could:

[Source_Data]:

LOAD *

FROM DB1;

CONCATENATE

LOAD *

FROM DB2;

[Result]:

LOAD DISTINCT

     *

RESIDENT Source_Data;

View solution in original post

5 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

Any reason you cant do the join in the database? Like:

SQL SELECT

     D1.Person

FROM DataBase1 D1

LEFT JOIN Database2 D2

     On D1.Person = D2.Person;

(assuming by database you mean a database table)

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable

you could look into the Exists function: The exists issue

(that article mentions the drawback with the Exists function - but also gives a usage example)

Otherwise, you could:

[Source_Data]:

LOAD *

FROM DB1;

CONCATENATE

LOAD *

FROM DB2;

[Result]:

LOAD DISTINCT

     *

RESIDENT Source_Data;

sfatoux72
Partner - Specialist
Partner - Specialist

Try this,  :

  • Add distinct on each request if you could have duplicate on it
  • Add "Where not Exist(Person)" to load from the second request only new Person

Table1_2:

LOAD distinct

*

;

SQL SELECT

Person

FROM DataBase1;

Table1_2:

LOAD distinct

*

;

SQL SELECT

Person

FROM DataBase1

WHERE not exists(Person);

simotrab
Creator III
Creator III
Author

I'm sorry, but I cannot do this: I've not been clear about this (my fault).

simotrab
Creator III
Creator III
Author

Thanks, these are great topics.