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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Using data in loaded table to limit SQL WHERE

Hello!

I have two tables in an SQL database.

One contains records, and looks a bit like this:

ID numberDescriptionResolutionAssigned Agent
1Forgotten password.User given new password.Hans
2User complains about loud beeping noise.User had two keyboards and was using one to put things on.Gretel
4User cant find printer.Guided the user, printer was on his desk.Tits McGee

The other one contains multiple rows of data for each record in the first table, like this:

ID NumberAction TypeDate
1Record Opened2014-01-01
1Description Changed2014-01-04
1Record Closed2014-01-11
3Record Opened2014-01-23
4Record Opened2014-02-09
5Record Opened2014-03-11

Now, what I want to do is import the entire first table, and then get the rows with the corresponding ID-numbers from the second table and store into a seperate table in quickview.

In other words, somthing like this:

Facts:

     LOAD

          [ID number];

SQL Select

     [ID number]

FROM

Table1;

Details:

     LOAD

          [Action Type];

SQL Select

     [Action Type]

FROM

     Table2

WHERE

     table2.[ID number] in Facts;

However, I get an error message complaining about incorrect syntax.

Is it possible to use a value from a previous LOAD in the next SQL WHERE statement? The WHERE-statement is in the SQL-query so I was thinking I should be using SQL-syntax and not Qlikview's funtions. Perhaps I'm doing it completely wrong? I need to keep the data in seperate tables once loaded into qlikview, no joins.

I'm guessing I could also just get the entire Table2 in the SQL Select and then limit my data in the LOAD with the match() function or something, but wouldn't that put a bigger strain on my database server? The real tables are millions of rows each.

Thanks in advance.

12 Replies
Not applicable
Author

Thank you very much for your responses, I wish I could mark them all as correct

I used LEFT KEEP before the second load and it did exactly what I needed.

This is my finished load-script:

Facts:

     LOAD

          [ID number];

SQL Select

     [ID number]

FROM

Table1;

Details:

LEFT KEEP LOAD

          [ID Number],

          [Action Type];

SQL Select

     [ID number],

     [Action Type]

FROM

     Table2

Not applicable
Author

This answered my question, thank you very much!

Not applicable
Author

Thank you! Left keep was the solution!