Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
JayKay07
Contributor III
Contributor III

Join Multiple Tables in Qlik

Hello,

I am new to Qlik and having difficulty in joining tables. Below is my code in SQL, can you please help to write in Qlik language?

SELECT C.Customer_ID, C.Customer_Name, C.Address_ID, O.Product_Name, A.Address_ID, A.City
FROM
Customers AS C
LEFT JOIN Orders AS O ON C.Customer_ID = O.Customer_ID
LEFT JOIN Addresses AS A ON C.Address_ID = A.Address_ID

 

Thank you

Labels (2)
6 Replies
jerifortune
Creator III
Creator III

Customer:
LOAD
  Customer_ID,
Customer_Name,
Address_ID
Resident Customer;    // specify the location of the customer table here 

LEFT JOIN (Customer):
LOAD 
  AddressID,
City
Resident Addresses ;  // specify the location of the addresses  table here 

LEFT JOIN (Customer):
LOAD 
  Customer_ID,
Product_Name
Resident Orders ;  // specify the location of the orders  table here 

You can create an Extractor Apps that converts the tables to QVDs and load directly from the qvd files. 

dwforest
Specialist II
Specialist II

If you want the same output of a single table, just use SQL as is, no point in re-writing in Qlik  script.

Otherwise Join syntax:

https://help.qlik.com/en-US/sense/November2019/Subsystems/Hub/Content/Sense_Hub/Scripting/ScriptPref...

Essentially you don't provide the "on clause" as Qlik "automatically" joins based on field names being equal.

JayKay07
Contributor III
Contributor III
Author

Thank you for your response. Is there a way that I can join manually (by writing script). Sometimes Qlik's joining is not what I want. Thanks.

Marcos_rv
Creator II
Creator II

 
 

Hi, try use SQL DEPsql.png

JayKay07
Contributor III
Contributor III
Author

How do I get Qlik code in SQL Dep?

Marcos_rv
Creator II
Creator II

SQL SELECT C.Customer_ID, C.Customer_Name, C.Address_ID, O.Product_Name, A.Address_ID, A.City
FROM
'schema'.Customers AS C
LEFT JOIN 'schema'.Orders AS O ON C.Customer_ID = O.Customer_ID
LEFT JOIN 'schema'.Addresses AS A ON C.Address_ID = A.Address_ID;


if you need to pass that query to qlik, you should only add 'SQL' in front of the query, also the full name of the table (the schema), in each part where the table is being referenced, you would do this to have a table in direct qlik of sql without having to download each table and work it in QLIK, it is not the best practice but if you do not have time it can help you.

Regards!!!