Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Good morning and good Monday everyone!
I need to find the differences (the different fields) between two tables.
For example:
Table A:
A1 Bzw998
A2 Cdw955
A3 Yxp900
A5 Djj244
A7 Mnw104
A8 Vbc456
A9 Rtk777
Table B:
A1 Bzw998
A2 Cdw955
A4 Ghk888
A5 Djj244
A6 Ell777
A7 Mnw104
A8 Vbc456
Table result:
A3 Yxp900
A4 Ghk888
A6 Ell777
A9 Rtk777
How can I do this?
Maybe with OUTER JOIN?
Thanks in advance!
Hi,
Try below code.
This will clear your idea.
Inclusion:
Load id as Temp_ID FROM a;
Inner Join
Load id as Temp_ID FROM b;
Exclusion:
Load id,name FROM A Where not exists(Temp_ID,id);
Concatenate
Load id,name FROM B Where not exists(Temp_ID,id);
Drop table Inclusion;
Regards,
Kaushik Solanki
also run this code
TableA:
load * inline [
id, name
A1, Bzw998
A2, Cdw955
A3, Yxp900
A5, Djj244
A7, Mnw104
A8, Vbc456
A9, Rtk777
];
join
TableB:
load * inline [
id, name
A1, Bzw998
A2, Cdw955
A4, Ghk888
A5, Djj244
A6, Ell777
A7, Mnw104
A8, Vbc456
];
Result:
load id as newid, name as newname
resident TableA
where match(id,'A3','A9','A4','A6');
drop table TableA;
then output like this
newid | newname |
A3 | Yxp900 |
A4 | Ghk888 |
A6 | Ell777 |
A9 | Rtk777 |
Thanks vishwaranjan.
But I'm finding a generic solution.
The tables mentioned are examples, but the fields are not fix.
I will use the script to find the differences between a txt result of reading each bar code from clothes from our provider and compare the fields with our reading.
Thanks.
Hi,
Try below code.
This will clear your idea.
Inclusion:
Load id as Temp_ID FROM a;
Inner Join
Load id as Temp_ID FROM b;
Exclusion:
Load id,name FROM A Where not exists(Temp_ID,id);
Concatenate
Load id,name FROM B Where not exists(Temp_ID,id);
Drop table Inclusion;
Regards,
Kaushik Solanki
Thank you very much Kaushik!
It works
Thanks Kaushik. I was facing this problem until I've found your post.