Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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.
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:
Essentially you don't provide the "on clause" as Qlik "automatically" joins based on field names being equal.
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.
Hi, try use SQL DEP
How do I get Qlik code in SQL Dep?
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!!!