Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
tab1
--------
id name
---------
1 a
2 b
3 c
tab2
--------
id name
---------
1 a
4 c
5 f
I want to find out those list of records
only present in tab1 and tab2
I want to implement it in the script level
Hi,
Using the Exists() clause would do, among some other ways:
tab1:
LOAD * INLINE [
id, name
1, a
2, b
3, c
];
tab2:
LOAD * INLINE [
id2, name2
1, a
4, c
5, f
];
InBothTables:
LOAD *,
1 AS Dummy
RESIDENT tab1
WHERE Exists(id2, id);
CONCATENATE LOAD id2 as id,
name2 as name,
1 AS Dummy
RESIDENT tab2
WHERE Exists(id, id2);
DROP TABLES tab1, tab2;
DROP FIELD Dummy
Hope that helps.
Miguel
Hi,
Using the Exists() clause would do, among some other ways:
tab1:
LOAD * INLINE [
id, name
1, a
2, b
3, c
];
tab2:
LOAD * INLINE [
id2, name2
1, a
4, c
5, f
];
InBothTables:
LOAD *,
1 AS Dummy
RESIDENT tab1
WHERE Exists(id2, id);
CONCATENATE LOAD id2 as id,
name2 as name,
1 AS Dummy
RESIDENT tab2
WHERE Exists(id, id2);
DROP TABLES tab1, tab2;
DROP FIELD Dummy
Hope that helps.
Miguel
You can do Inner Join between the tables.
Both:
LOAD ID, NAME AS T1_NAME FROM TAB1;
INNER JOIN
LOAD ID, Name as T2_NAME FROM TAB2;
These two tables Join in ID key.
May be you can try with inner keep.
tab1:
Load
id,
name
FROM ...
tab2:
NoConcatenate
Inner Keep
Load
id,
name
FROM ...
may be my expression was wrong.
I took help from your query and modified this.It is working fine.
Thanks to all for their contribution.
InBothTables:
LOAD *,
1 AS Dummy
RESIDENT tab1
WHERE not Exists(id2, id);
CONCATENATE
LOAD id2 as id,
name2 as name,
1 AS Dummy
RESIDENT tab2
WHERE not Exists(id, id2);
DROP TABLES tab1, tab2;
DROP FIELD Dummy ;