Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
larouge69
Contributor III
Contributor III

WHERE Clauses in SQL Queries

Hi All,

I'm wondering if there is a way to make a load script using a SQL query with dynamic update of the where clause ?

Example :

Id_Customers:

LOAD

Id_Customers

FROM

FileA;

 

SQL SELECT

Customer_Id, Customer_name

FROM customers

Where customers.Customers_Id = (or in) Id_Customers (this data come from the file load above);

 

Thanks

 

 

Labels (1)
1 Solution

Accepted Solutions
maxgro
MVP
MVP

Try with a variable 

 

Id_Customers:
LOAD * INLINE [
Id_Customers
1
2
3
];

TMP2:
LOAD CONCAT(Id_Customers, ', ') as Field2 RESIDENT Id_Customers;

LET vField2= PEEK('Field2', 0, 'TMP2');     // vField2 = 1, 2, 3

SQL SELECT Customer_Id, Customer_name
FROM customers
Where customers.Customers_Id IN ($(vField2))
;

View solution in original post

2 Replies
maxgro
MVP
MVP

Try with a variable 

 

Id_Customers:
LOAD * INLINE [
Id_Customers
1
2
3
];

TMP2:
LOAD CONCAT(Id_Customers, ', ') as Field2 RESIDENT Id_Customers;

LET vField2= PEEK('Field2', 0, 'TMP2');     // vField2 = 1, 2, 3

SQL SELECT Customer_Id, Customer_name
FROM customers
Where customers.Customers_Id IN ($(vField2))
;

vinieme12
Champion III
Champion III

Alternatively you can use EXISTS()

 

Example :

Id_Customers:

LOAD

Id_Customers

FROM

FileA;

 

TableB:

Load * 

Where Exists(Id_Customers,Customers_Id);

SQL SELECT

Customer_Id, Customer_name

FROM customers;

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.