One Star

Question on tmap to use Or condition in join

Hi,
I would like to use or condition tmap while joining with a lookup table. Can anyone share how that can be done? Below, i have given the table structure and join query. I want to achieve join query using tmap. How can i do that?
Table A (Main Table)
----------
Name,
Id_1,
Id_2
Table B (Lookup Table)
------------
Table B (Lookup)
------------------
Id,
Address,
Region
SELECT A.NAME, B.ADDRESS, B.REGION
FROM A, B
WHERE A.ID_1 = B.ID OR A.ID_2 = B.ID
6 REPLIES
Seven Stars

Re: Question on tmap to use Or condition in join

The best way, I think, is to have two left-join lookups from Table B with an appropriate condition on your output e.g. Lookup1.Address != null || Lookup2.Address != null
Moderator

Re: Question on tmap to use Or condition in join

Hi sree,
To make you clear, I have designed a demo job with troubleshoots.
Here are two files
1(main)
id;id1
12;24
13;26
15;30
2(lookUP)
id;name;address;region
12;dan;uk;LD
26;petter;uk;SF
15;merry;US;NY
24;shong;china;hn
60;sabrina;china;bj
The work flow is : tFileInputDelimited-->tMap-->tLogrow
Please see the screenshots for details

Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
One Star

Re: Question on tmap to use Or condition in join

Thanks for the replies. I will try and let you know if there are more questions.
Seven Stars

Re: Question on tmap to use Or condition in join

 
What if 
 table 1 consis of ID and Name and Table two Consist of ID1, ID2 and Table 1 is main in tmap and Table 2 is Lookup 
. how to sort this out?? @xdshi

 

Twelve Stars

Re: Question on tmap to use Or condition in join

Try this way.

row1.id==row2.id1 || row1.id==row2.id2
Manohar B
Seven Stars

Re: Question on tmap to use Or condition in join

Thank You So much @manodwhb

It works very well.