Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

INNER JOIN IN SQL SCRIPT

Hi,

I have a csv file containing a list of users.

I want to write a query such that it retrieves info only for the users in the csv.

I am trying to write something like:

connections:

SQL

SELECT * FROM (

     SELECT

          A,

          B,

          C

     FROM

          Table1,

          Table2

     WHERE

          conditions..

) a

INNER JOIN (

     SELECT

          X,

          Y

     FROM

          (upload contents of csv file)

) b

ON a.B = b.X;

How do I load the csv file in the script with label SQL?

OR, if I load the csv before the script as follows:

[file]:

LOAD

     @1 as A,

     @2 as B

FROM [file-path]

(txt, codepage is 28591, embedded labels, delimiter is ',', msq);

How do I use the columns A,B in the SQL script?

Thanks!

1 Solution

Accepted Solutions
sunny_talwar

Something like this

[file]: 

LOAD Concat(Chr(39) & B & Chr(39), ', ') as ConcatenatedB;

LOAD 

     @1 as A, 

     @2 as

FROM [file-path] 

(txt, codepage is 28591, embedded labels, delimiter is ',', msq);


Let vB = Peek('ConcatenatedB');


Now pass vB to your SQL...

View solution in original post

4 Replies
sunny_talwar

May be store the content of field B in a variable and pass it on the SQL query via the variable

Anonymous
Not applicable
Author

Field B has multiple rows. How do I handle that?

sunny_talwar

Something like this

[file]: 

LOAD Concat(Chr(39) & B & Chr(39), ', ') as ConcatenatedB;

LOAD 

     @1 as A, 

     @2 as

FROM [file-path] 

(txt, codepage is 28591, embedded labels, delimiter is ',', msq);


Let vB = Peek('ConcatenatedB');


Now pass vB to your SQL...

Anonymous
Not applicable
Author

Thank you so much!