Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Jacob_Weig
Contributor III
Contributor III

Concatenate two table with the same key values

Hello, 

I have got two tables:

Table 1:

id , name, age

1, John, 23

2, Pablo,25

3, Steve, 26

Table 2

1, Jake, 34

2, Maria, 40

3, Lara, 34

I know how to concatenate them into one table. The problem is that I do not want their id's to be repeated. I also have other tables that join with those id's, so not only I need new id's for table 2 , but I need to change them in the other tables as well. Anyone know what would be the best approach?

Thanks!

Marcela

Labels (2)
2 Replies
maxgro
MVP
MVP

you can rowno() to create a newid

Table1:
load * inline [
id , name, age
1, John, 23
2, Pablo,25
3, Steve, 26
];

Table2:
NOCONCATENATE load * inline [
id , name, age
1, Jake, 34
2, Maria, 40
3, Lara, 34
];

Table:
LOAD rowno() as newid, name, age RESIDENT Table1;
LOAD rowno() as newid, name, age RESIDENT Table2;

DROP TABLES Table1, Table2;

 

 

maxgro_0-1663164241192.png

 

Jacob_Weig
Contributor III
Contributor III
Author

Hello,

The problem is that that same key is used to join other tables. So for example additionally I have this table:

sales_table1 (which should only be linked with table 1):

sale_id, id (from previous table),sales_amount

1,1,900

.....

sales_table2 (which actually should be linked only with table 2):

sale_id, id (from previous table),sales_amount

1,3,400

 

So as you see, my problem is I have two databases which are basically identical, but where the ids are repeated but with different data