<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How can I join 2 tables to create a new table with the given conditions? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-join-2-tables-to-create-a-new-table-with-the-given/m-p/353273#M104560</link>
    <description>&lt;P&gt;So this is what I want to do, and I don't know if Splunk can do this. &lt;/P&gt;

&lt;P&gt;This is the result for Table A&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Table A
hostA         brand
aaa          ios
bbb         nxos
ddd         metamako 
ccc          arista
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This the result for table B&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Table B
hostB            user
aaa-l1          user1
bbb-l1         user2
ddd-l1         user3 
ccc-l1           user4
kkk-l1          user5
klo-l1           user6
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want the join match &lt;CODE&gt;TableA(hostA)&lt;/CODE&gt; with &lt;CODE&gt;TableB(hostB)&lt;/CODE&gt; where like&lt;CODE&gt;(hostB,"%"+hostA+"%")&lt;/CODE&gt;&lt;BR /&gt;
and the result will be&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; TableC
hostA            brand                    hostB            user
aaa                ios                          aaa-l1          user1
bbb               nxos                       bbb-l1         user2
ddd               metamako             ddd-l1         user3  
ccc                 arista                      ccc-l1           user4
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 01 Feb 2018 15:18:48 GMT</pubDate>
    <dc:creator>gts_ame_tfo_cty</dc:creator>
    <dc:date>2018-02-01T15:18:48Z</dc:date>
    <item>
      <title>How can I join 2 tables to create a new table with the given conditions?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-join-2-tables-to-create-a-new-table-with-the-given/m-p/353273#M104560</link>
      <description>&lt;P&gt;So this is what I want to do, and I don't know if Splunk can do this. &lt;/P&gt;

&lt;P&gt;This is the result for Table A&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Table A
hostA         brand
aaa          ios
bbb         nxos
ddd         metamako 
ccc          arista
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This the result for table B&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Table B
hostB            user
aaa-l1          user1
bbb-l1         user2
ddd-l1         user3 
ccc-l1           user4
kkk-l1          user5
klo-l1           user6
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want the join match &lt;CODE&gt;TableA(hostA)&lt;/CODE&gt; with &lt;CODE&gt;TableB(hostB)&lt;/CODE&gt; where like&lt;CODE&gt;(hostB,"%"+hostA+"%")&lt;/CODE&gt;&lt;BR /&gt;
and the result will be&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; TableC
hostA            brand                    hostB            user
aaa                ios                          aaa-l1          user1
bbb               nxos                       bbb-l1         user2
ddd               metamako             ddd-l1         user3  
ccc                 arista                      ccc-l1           user4
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 01 Feb 2018 15:18:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-join-2-tables-to-create-a-new-table-with-the-given/m-p/353273#M104560</guid>
      <dc:creator>gts_ame_tfo_cty</dc:creator>
      <dc:date>2018-02-01T15:18:48Z</dc:date>
    </item>
    <item>
      <title>Re: How can I join 2 tables to create a new table with the given conditions?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-join-2-tables-to-create-a-new-table-with-the-given/m-p/353274#M104561</link>
      <description>&lt;P&gt;If the actual data is as straight forward as your example, then you can just add a calculated field to table B with the truncated hostname and use that to join?&lt;/P&gt;

&lt;P&gt;But given that you are asking for a like(hostB,"%"+hostA+"%") that seems to imply the actual case is more complex than your example?&lt;/P&gt;</description>
      <pubDate>Thu, 01 Feb 2018 15:58:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-join-2-tables-to-create-a-new-table-with-the-given/m-p/353274#M104561</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2018-02-01T15:58:52Z</dc:date>
    </item>
    <item>
      <title>Re: How can I join 2 tables to create a new table with the given conditions?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-join-2-tables-to-create-a-new-table-with-the-given/m-p/353275#M104562</link>
      <description>&lt;P&gt;let me show you a real example &lt;/P&gt;

&lt;P&gt;table A&lt;BR /&gt;
host&lt;BR /&gt;
tor-rt-dist02-03&lt;BR /&gt;
tor-rt-dist01&lt;BR /&gt;
tor-rt-wan01&lt;BR /&gt;
tor-rt-wan02&lt;BR /&gt;
tor-rt-ext01&lt;BR /&gt;&lt;BR /&gt;
tor-rt-ext02&lt;/P&gt;

&lt;P&gt;TableB&lt;BR /&gt;
host&lt;BR /&gt;
tor-rt-dist02-03-l1&lt;BR /&gt;
tor-rt-dist01-l1-3&lt;BR /&gt;
tor-rt-wan01-l2-1&lt;BR /&gt;
tor-rt-wan02-eth1-3&lt;/P&gt;

&lt;P&gt;so as you can see with this example i cannot add  truncated hostname and use that to join because sometime  "tor-rt-wan01-l2-1" and sometime the hostname "tor-rt-wan02-eth1-3" so i cannot add a regex to extart and join.&lt;/P&gt;

&lt;P&gt;is there any way to make it work ?&lt;/P&gt;</description>
      <pubDate>Thu, 01 Feb 2018 16:12:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-join-2-tables-to-create-a-new-table-with-the-given/m-p/353275#M104562</guid>
      <dc:creator>gts_ame_tfo_cty</dc:creator>
      <dc:date>2018-02-01T16:12:01Z</dc:date>
    </item>
    <item>
      <title>Re: How can I join 2 tables to create a new table with the given conditions?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-join-2-tables-to-create-a-new-table-with-the-given/m-p/353276#M104563</link>
      <description>&lt;P&gt;If you could share your exact host value so that accordingly field can be build which will use for join&lt;/P&gt;</description>
      <pubDate>Thu, 01 Feb 2018 16:14:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-join-2-tables-to-create-a-new-table-with-the-given/m-p/353276#M104563</guid>
      <dc:creator>493669</dc:creator>
      <dc:date>2018-02-01T16:14:03Z</dc:date>
    </item>
    <item>
      <title>Re: How can I join 2 tables to create a new table with the given conditions?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-join-2-tables-to-create-a-new-table-with-the-given/m-p/353277#M104564</link>
      <description>&lt;P&gt;thanks you for the answer,&lt;/P&gt;

&lt;P&gt;let me give you a real example &lt;/P&gt;

&lt;P&gt;TableA&lt;BR /&gt;
host&lt;BR /&gt;
tor-rt-dist02-3&lt;BR /&gt;
tor-rt-dist01&lt;BR /&gt;
tor-rt-wan01-6&lt;BR /&gt;
tor-rt-wan02&lt;BR /&gt;
tor-rt-ext01&lt;BR /&gt;
tor-rt-ext02&lt;/P&gt;

&lt;P&gt;TableB&lt;BR /&gt;
host&lt;BR /&gt;
tor-rt-dist02-3-l0-6&lt;BR /&gt;
tor-rt-dist01-l1-26&lt;BR /&gt;
tor-rt-wan01-6-eth0&lt;BR /&gt;
tor-rt-wan02-mgmt0&lt;/P&gt;

&lt;P&gt;here is some of the hosts &lt;/P&gt;</description>
      <pubDate>Thu, 01 Feb 2018 16:27:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-join-2-tables-to-create-a-new-table-with-the-given/m-p/353277#M104564</guid>
      <dc:creator>gts_ame_tfo_cty</dc:creator>
      <dc:date>2018-02-01T16:27:36Z</dc:date>
    </item>
    <item>
      <title>Re: How can I join 2 tables to create a new table with the given conditions?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-join-2-tables-to-create-a-new-table-with-the-given/m-p/353278#M104565</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/92181"&gt;@gts_ame_tfo_cty&lt;/a&gt;,&lt;BR /&gt;
Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;query&amp;gt; |  table hostA brand | rename hostA as host | join type=inner host [search &amp;lt;query&amp;gt;| rex field=hostB "(?&amp;lt;host&amp;gt;^[^\d]+\d+(\-\d+)*)" | table host user]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Let me know if it works!&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 17:53:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-join-2-tables-to-create-a-new-table-with-the-given/m-p/353278#M104565</guid>
      <dc:creator>493669</dc:creator>
      <dc:date>2020-09-29T17:53:19Z</dc:date>
    </item>
    <item>
      <title>Re: How can I join 2 tables to create a new table with the given conditions?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-join-2-tables-to-create-a-new-table-with-the-given/m-p/353279#M104566</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/92181"&gt;@gts_ame_tfo_cty&lt;/a&gt; please share your query for Table A and Table B. Also make sure you use the Code Button 101010 on Splunk Answers while posting your queries so that special characters in them do not escape.&lt;/P&gt;

&lt;P&gt;PS: Adding four spaces before each line of code will also format the entire content as code.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 17:56:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-join-2-tables-to-create-a-new-table-with-the-given/m-p/353279#M104566</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2020-09-29T17:56:33Z</dc:date>
    </item>
  </channel>
</rss>

