Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello Viewers,
There are 2 tables
In 1st table contains 10 records(emp id)
Now I have loaded 2nd table contains 25 records(emp id)
Now I want to create a flag in 2nd table with
Exists(If already exists in 1st table) and
new(If it is new record)
How to accomplish this ????
Please help!!!
Try like this
Table1:
LOAD
EMP_ID,
...
Table2:
LOAD
EMP_ID,
If(Exists(EMP_ID)='-1','Yes','No') as Flag,
...
May be like this:
LOAD [emp id],
[emp id] as temp_emp_id
....
FROM Table1;
LOAD [emp id],
If(Exists(temp_emp_id, [emp id]), 'Existing', 'New') as Flag,
....
FROM Table2;
Try like this
Table1:
LOAD
EMP_ID,
...
Table2:
LOAD
EMP_ID,
If(Exists(EMP_ID)='-1','Yes','No') as Flag,
...
LOAD *,
emp_id as Check_Emp_Id
FROM Table1;
LOAD *,
emp_id ,
If(Exists(emp_id ,Check_Emp_Id), 'Exists', 'New') as Flag,
FROM Table2;
Check fr emp_id frm table 2's existnace in Table one's Check_Emp_Id
Try
Sachin I think the order within Exists is nor right.... I think it should be
If(Exists(Check_Emp_Id, emp_id), 'Exists', 'New') as Flag,
try this
:
LOAD * INLINE [
emp, name
1, fsfg
2, dds
3, aaas
4, aa
5, gdg
];
b:
LOAD * INLINE [
emp, name
1, fsfg
2, dds
3, aaas
4, aa
5, gdg
6,gg
7,hh
8,rr
];
Left Join (a)
LOAD emp,
Sign(Count(emp)-1) as MultNameFlag
Resident a
Group By emp;
Thank you guys for your quick response.
Both are helpful.
But I really don't understand
Exists(emp_id)='-1'
Can you please elaborate this(what describes '-1')??
HI Sunny I think its correct only:
If(Exists(emp_id ,Check_Emp_Id), 'Exists', 'New') as Flag,
By saying this I m checking emp_id frm table to present in Check_Emp_Id of table 1.
@ Babi.... plss verify once..
Sachin
Exists() function return an integer value so if its true then it returns -1 else 0
Sachin, Order should be First loaded column name first and then the second loaded column so it should be
Exists(First table loaded column name ,Second table loaded column name)