Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have two table
Name, flag
Neil T,1
Tom k,1
and
SName
Tom k wahis
Neil T
Neil T katt
Tom k
now i want to compare and write flag value infront of sName.
if full string match or substring match .then i want below
SName,Flag
Tom k wahis,1
Neil T,1
Neil T katt,1
Tom k,1
ex: Neil T and substring of Neil T katt in field Sname is matching with Neil T in Name.
hence the flag infront of Neil T in Name should assign to
Neil T
Neil T katt
this is what i required.
Hi,
you could do this with MapSubstring() to build a lookup with substring matching (even if it looks a bit strange in code):
T1:
LOAD * INLINE [
Name, flag
Neil T, 1
Tom k, 1
Neil U, 2
Tom l, 3
];
// added some more test cases:
T2:
NOCONCATENATE LOAD * INLINE [
Name
Tom k wahis
Neil T
Neil T katt
Tom k
Neil U fre
Tom l xy
Neil V
Tom m
];
MapName:
Mapping LOAD '#' & Name, flag & ';' Resident T1; // # = only match from left
SName:
NOCONCATENATE LOAD Name, if(left(flag,1)='#', Null(), flag) as flag;
LOAD Name, SubField(MapSubString('MapName', '#' & Name), ';', 1) as flag
Resident T2;
Drop Tables T1, T2;
- Ralf
Hi,
you could do this with MapSubstring() to build a lookup with substring matching (even if it looks a bit strange in code):
T1:
LOAD * INLINE [
Name, flag
Neil T, 1
Tom k, 1
Neil U, 2
Tom l, 3
];
// added some more test cases:
T2:
NOCONCATENATE LOAD * INLINE [
Name
Tom k wahis
Neil T
Neil T katt
Tom k
Neil U fre
Tom l xy
Neil V
Tom m
];
MapName:
Mapping LOAD '#' & Name, flag & ';' Resident T1; // # = only match from left
SName:
NOCONCATENATE LOAD Name, if(left(flag,1)='#', Null(), flag) as flag;
LOAD Name, SubField(MapSubString('MapName', '#' & Name), ';', 1) as flag
Resident T2;
Drop Tables T1, T2;
- Ralf
I salute your idea man