Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
How can I replace data?
I have two tables, and I wanna replace a name:
Table1:
ID,Name,Age
1,Luis,15
Table2:
ID,Name,Age
1,Marina,15
I need put the value for name in the first table, in the second, if the combination of ID,Age is the same
Table2:
ID,Name,Age
1,Luis,15
You can use a mapping table to replace the names in table 2 with the names of table 1, something along these lines:
Table1:
LOAD * INLINE [
ID,Name,Age
1,Luis,15
];
NAMEMAP:
MAPPING LOAD
ID&'-'&Age as Key,
Name
Resident Table1;
Table2:
LOAD ID,
applymap('NAMEMAP', ID&'-'&Age, Name) as Name,
Age
INLINE [
ID,Name,Age
1,Marina,15
1,Marina,16
];
You can use a mapping table to replace the names in table 2 with the names of table 1, something along these lines:
Table1:
LOAD * INLINE [
ID,Name,Age
1,Luis,15
];
NAMEMAP:
MAPPING LOAD
ID&'-'&Age as Key,
Name
Resident Table1;
Table2:
LOAD ID,
applymap('NAMEMAP', ID&'-'&Age, Name) as Name,
Age
INLINE [
ID,Name,Age
1,Marina,15
1,Marina,16
];
What's ID&'-'&Age?
Thanks
& id the string concatenation operator in QV, so ID&'-'&Age is creating a new string by concatenating field ID and field Age with an additional '-' in the middle (as separator).
As I understood, you'll need to check for same ID and age, then replace the name by the name found in table 1, correct?
Yes