Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Milo2009
Contributor II
Contributor II

Wrong SQL results - Inner Join vs. Left Join

Hey,

I have a question concerning a SQL Select in QlikView. I have to join two tables (Table A and Table B) to get some specific data into one QlikView-Table.

Table A

ARTNRBC
1......
2......
3......
4......
5......
6......

Table B

NR2NR...
190...
2...
350...
450...
5...
6100...

The blank fields in the column 2NR are Null Values in the database.

With the following SQL-Statement I got the expected result:

SQL Select

     ARTNR,

     B,

     C,

     2NR

FROM

TABLE_A

LEFT JOIN TABLE_B ON ARTNR = NR;


When I use an Inner Join instead a Left Join (what can be necessary in some use-cases) I got a wrong result:

SQL Select

     ARTNR,

     B,

     C,

     2NR

FROM

TABLE_A

INNER JOIN TABLE_B ON ARTNR = NR;


In the case of an Inner Join my result table looks like this:

ARTNRBC2NR
1......90
2......90
3......50
4......50
5......50
6......100

I have marked the wrong field values red. As you can see there are values in the result table, although in Table B there aren't any values for the ARTNR 2 and 5 in the field 2NR. When I use a Left Join this field values are Null in my result table.


So does anybody have an idea, why I get the wrong results when using an Inner Join in QlikView - in MS Access I get the correct results when using an Inner Join.


Thanks in advance:)

1 Reply
sunny_talwar

I don't know why the numbers are not coming out right, but you need to realize that you are not joining (inner or left) in QlikView. The joins are taking place in SQL also. QlikView is just picking up the value of those joins and displaying them. May be something else in your script might be doing this? You have only pasted the SQL code, so difficult to see what the issue could be. But I would suggest exploring options beyond just the joins cause to me it doesn't make sense that QlikView or SQL will arbitrarily pick a value from above and display it.