Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
JPbeginner
Contributor
Contributor

how to join two tables from different data source

hi community,

i'm new to Qlik and SQL, and facing a trouble.

i am trying to join two tables from different source, but cannot achieve it.

 i can join two tables from same source, but cannot in case from different source.

what is the best way to join tables  from different source? i feel multiple "lib connect to" statement makes me confused.

 

 my dataload script is like below:

LIB CONNECT TO sourceA;

LOAD

ItemID, WEIGHT

from tableA

;

LIB CONNECT TO sourceB

LOAD

targetID, machinePG

from tableB

 

INNER JOIN (tableA)

ON tableA.itemID=tableB.targetID

 

 

Labels (2)
1 Solution

Accepted Solutions
mfchmielowski
Creator II
Creator II


tableA:
LOAD

ItemID, WEIGHT

inline [
	ItemID, WEIGHT
    1,10
    2,20
]
;

INNER JOIN (tableA)
LOAD
targetID as ItemID, machinePG
inline [
	targetID, machinePG
    1,1
    3,4
]
;​

Qlik engine joins on table name. In code sample i've used load inline syntax. It will work with libs also.

View solution in original post

2 Replies
mfchmielowski
Creator II
Creator II


tableA:
LOAD

ItemID, WEIGHT

inline [
	ItemID, WEIGHT
    1,10
    2,20
]
;

INNER JOIN (tableA)
LOAD
targetID as ItemID, machinePG
inline [
	targetID, machinePG
    1,1
    3,4
]
;​

Qlik engine joins on table name. In code sample i've used load inline syntax. It will work with libs also.

mk1dangi21
Contributor II
Contributor II

 

  1. Load data from the first data source:

LIB CONNECT TO sourceA;

TableA:
LOAD
ItemID,
WEIGHT
FROM tableA;

 

 

  1. Load data from the second data source:
 

LIB CONNECT TO sourceB;

TableB:
LOAD
targetID as ItemID, // Rename 'targetID' to 'ItemID' to create an association based on the same field name
machinePG
FROM tableB;

 

  1. Close the script with a semicolon.