Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Left Join in Data Load Editor not working

Hi Community. What I am trying to achieve is a simple Left Join. Nevertheless, I am not getting the results I am expecting.

I have a table called Customers:

table a.png

Then I have a 2nd table called Operations:

tableb.png

What I want to create is a new table Results left join so that I can have information of registries of table Customers whose ID_CUSTOMER also appears in the table Operations as ID_BUYER. Something like:

tablec.png

I have tried the following code in Data Load editor without success:

LET vData = 'lib://data';

customers:

load *

From '$(vData)/customers.csv';

operations:

load *,

ID_BUYER AS ID_CUSTOMER

From '$(vData)/operations.csv';

DROP FIELD ID_BUYER;

Left Join (operations)

Load

NAME as i_name,

AGE as i_age,

HEIGHT as i_height,

PROFESSION as i_profession,

NATIONALITY as i_nationality

Resident customers;

The result of what I am getting is a cartesian product of my desired "Left join" table with 12 fields and 30 rows instead of 5 rows with 12 fields as it can be seen in my third image. I know I have a missing statement or condition. Any help is highly appreciated. Thanks, Anibal

1 Solution

Accepted Solutions
sunny_talwar

Where is ID_CUSTOMER field in your Resident table? Also, why you have resident from clientes and not Customer Table? May be try the below

customers:

load *

From '$(vData)/customers.csv';

operations:

load *,

ID_BUYER AS ID_CUSTOMER

From '$(vData)/operations.csv';

DROP FIELD ID_BUYER;

Left Join (operations)

Load ID_CUSTOMER

NAME as i_name,

AGE as i_age,

HEIGHT as i_height,

PROFESSION as i_profession,

NATIONALITY as i_nationality

Resident customers;

View solution in original post

4 Replies
sunny_talwar

Where is ID_CUSTOMER field in your Resident table? Also, why you have resident from clientes and not Customer Table? May be try the below

customers:

load *

From '$(vData)/customers.csv';

operations:

load *,

ID_BUYER AS ID_CUSTOMER

From '$(vData)/operations.csv';

DROP FIELD ID_BUYER;

Left Join (operations)

Load ID_CUSTOMER

NAME as i_name,

AGE as i_age,

HEIGHT as i_height,

PROFESSION as i_profession,

NATIONALITY as i_nationality

Resident customers;

vinieme12
Champion III
Champion III

the field names must be same in both tables to perform a JOIN, you are missing the common field to perform the JOIN on

LET vData = 'lib://data';

customers:

load *

From '$(vData)/customers.csv';

operations:

load *,

ID_BUYER AS ID_CUSTOMER

From '$(vData)/operations.csv';

DROP FIELD ID_BUYER;

Left Join (operations)

Load

ID_CUSTOMER

NAME as i_name,

AGE as i_age,

HEIGHT as i_height,

PROFESSION as i_profession,

NATIONALITY as i_nationality

Resident clientes;

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

Hi Sunny, thank you very much for your answer. It is correct!

Table "clientes" was just a typo, and I changed it to "Customers" while you were answering my question; as this is a translation of an analogous example. Thanks a lot.

Anonymous
Not applicable
Author

Hi Vineeth, thank you for your response.

Totally right. I must have added column ID_CUSTOMER to get the results right. But bear in mind that I changed my example and removed table "clientes" as it was a typo. Thanks in advance.