Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Upew
Contributor III
Contributor III

Join between to table (from sql syntax)

Hello,

i'm trying to join 2 tables from sql syntax

first, i'm loading each sql syntax for each table, saving it as qvd file and then trying to do the join.

for some reason, its not working well.

the number of rows giving is not fit to the number of  row giving when doing the same join on sql developer.

this is the syntax that i'm writing on qlik:

Bakasha:

SQL

select distinct

mispar_bakasha,

date_created

from bakashot;

Store Bakasha into [lib://files/Bakasha.qvd] (qvd);

Drop table Bakasha;

Mea:

SQL

select distinct

process_inner_id AS MISPAR_BAKASHA,

process_name;

Store MEA into [lib://files/MEA.qvd] (qvd);

Drop TABLE MEA;

LOAD *

FROM [lib://files/Bakasha.qvd];

INNER JOIN (Bakasha)

LOAD *

FROM [lib://files/MEA.qvd];

Any suggestion how to do it well?

 

Thanks alot!

Labels (2)
2 Solutions

Accepted Solutions
marcus_sommer

Before going to the join, load the tables and check the data - especially on the key's. Are they loaded properly? Number of records and the content within the fields - before you store them and then after loading from the qvd's again.

Quite probably does anything not be like you would expect it - for example, in one table it are number and in the other it are strings or numbers/values are changed by removing leading zeros or spaces or similar stuff and so the key's didn't match anymore or previously different key's are now the same and causing duplicates. The simplest way to check for it respectively to avoid such trouble is to load the raw-data (here from the sql) per: text(Field) as Field.

View solution in original post

Upew
Contributor III
Contributor III
Author

whoho!

thanks alot! i found the problem! one of the "mispar bakasha" was a intger column and the other "mispar bakasha"

was a string column so the join didnt work properly.

i changed the srting to intger also and now its work perfectly!!

thanks everyone 🙂

View solution in original post

7 Replies
ogster1974
Partner - Master II
Partner - Master II

you've aliased AS MISPAR_BAKASHA in upper case where in your first table its lower case mispar_bakasha so wont join.

Upew
Contributor III
Contributor III
Author

Hello, thanks for the answer.

unfortunately this is not the problem.

i tried to change it to lower case and even then the join isn't working well.

when I'm association the tables without the join syntax i can see the link between them via "mispar bakasha" but the number of rows isnt making sense.

whem I'm using the join syntax for it, i can see it creating one table with the columns from both 2 tables but again, the number of rows isn't making sense.

i tired to wirte it on many ways but its giving me wrong number of rows all the time.

maby the join syntax isn't right?

 

ogster1974
Partner - Master II
Partner - Master II

Perhaps if you give some more information around what is "Wrong" i.e. current output using your various methods vs what you're expecting and we can help you better.

Upew
Contributor III
Contributor III
Author

Sure, i will try to:

some general information:

"Bakasha" table has 7k rows with "mispar_bakasha" as primary key for this table.

"Mea" table has 23k rows with "process_inner_id" as primary key for this table.

we connect the table with mispar_bakasha = procees_inner_id (i changed the name of process inner id to mispar_bakasha so qlik sense will know to associate between those 2 table with this column. 

when i do  the left join via SQL Dev, i'm getting 7k rows with no nulls.

now for qlik sense:

On my first try, I tried to associate this 2 table without any explicit join and i saw on the "data  load viewer"  that there is a link between the "mispar_bakasha" from the first table to "mispar_bakasha" from the second table. But, when i'm doing the review or even trying to make any graph, i can see that there is no data from the second table (its all on null).

 
on my second try, i tried to use the explict left join to "bakasha" table (like the syntax I wrote on my question) but now i'm getting around 15k rows.
 
i also tried to change the "load *" and i wrote the name of the columns instead of it and still, i got around 15k rows (instead of 7k which I expect).
 
Sorry if it's still not clear and if not, i would like to know if there is any tutorial videos for doing joins on qlik.
 
Thanks alot!
 
ogster1974
Partner - Master II
Partner - Master II

Here is some help around how joins work in Qlik Sense

https://help.qlik.com/en-US/sense/November2022/Subsystems/Hub/Content/Sense_Hub/Scripting/ScriptPref...

 

For trouble shooting your issue create a simple table of the output fields if you are expecting 7k rows and are getting 15k rows what's causing the rows to duplicate?  Can there be multiple process names against a mispar_bakasha for example.

marcus_sommer

Before going to the join, load the tables and check the data - especially on the key's. Are they loaded properly? Number of records and the content within the fields - before you store them and then after loading from the qvd's again.

Quite probably does anything not be like you would expect it - for example, in one table it are number and in the other it are strings or numbers/values are changed by removing leading zeros or spaces or similar stuff and so the key's didn't match anymore or previously different key's are now the same and causing duplicates. The simplest way to check for it respectively to avoid such trouble is to load the raw-data (here from the sql) per: text(Field) as Field.

Upew
Contributor III
Contributor III
Author

whoho!

thanks alot! i found the problem! one of the "mispar bakasha" was a intger column and the other "mispar bakasha"

was a string column so the join didnt work properly.

i changed the srting to intger also and now its work perfectly!!

thanks everyone 🙂