Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

SQL SELECT Dim_1, Dim2 FROM Table_1, Table_2 WHERE Table_1.Dim_1 <> Table_2.Dim_1

I need to load data from an sql table where Table_1.Dim_1 <> Table_2.Dim_1. Table_1 includes all records from Table_2 (Dim_1 is common Dim_2 differs) and looks like in the below example. The problem is that these two tables can be be bound only by Dim_1 so when I put code SQL SELECT Dim_1, Dim2 FROM Table_1, Table_2 WHERE Table_1.Dim_1 <> Table_2.Dim_1 it doesn't work. Please advise how to make it work.

BR, Przemek

Example:

Table_1:

Dim_1, Dim2

A, 2

B, 3

C, 5

D, 7

Table_2:

Dim_1, Dim_2

B, 9

D, 8



3 Replies
brenner_martina
Partner - Specialist II
Partner - Specialist II

Hi, Przemek,

mayby you need the funktion: exists() or Not exists()

Table:
Load Dim_1 as Firstfield,
Dim2
From Table_1;

Concatenate(Table)
Load Dim_1 as Firstfield,
Dim_2
From Table_2 Where Not Exists(Firstfield,Dim_1);

I hope that helps you

Dreamteam Solutions Germany

Not applicable
Author

It sounds like you need to rename dim2 in each load so that QlikView doesn't attempt to join on that field (making a synthetic key join). So, you could create SQL Statements as follows:

Table1:
LOAD Dim1, Table1Dim2;
SQL SELECT Dim1, Dim2 AS Table1Dim2 FROM ..............;
Table2:
LOAD Dim1, Table2Dim2;
SQL SELECT Dim1, Dim2 AS Table2Dim2 FROM ...............;


Good luck,

qliksus
Specialist II
Specialist II

Hi Martina,

Thanks. The solution realy helps me get my required solution.