<?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 Re: Join 2 tables for matching field values in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Join-2-tables-for-matching-field-values/m-p/240905#M71610</link>
    <description>&lt;P&gt;Have you tried the Out-Of-The-Box join? as described at &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Join"&gt;join&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 06 May 2016 23:07:13 GMT</pubDate>
    <dc:creator>ddrillic</dc:creator>
    <dc:date>2016-05-06T23:07:13Z</dc:date>
    <item>
      <title>Join 2 tables for matching field values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-2-tables-for-matching-field-values/m-p/240902#M71607</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I would like to join 2 tables with multiple fields based on  common field Column 1 where Table:1 will have fields like &lt;BR /&gt;
&lt;STRONG&gt;Table:1&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;
&lt;STRONG&gt;Column1          Column2                  Column3&lt;/STRONG&gt;&lt;BR /&gt;
xyz_sss_12          ghcgvcvb              dsdffgcg&lt;BR /&gt;
Bvc_tgg_hgh1    dfxxv                      hvhvhk&lt;BR /&gt;
Bvc_tgg_hgh2    uhuhgjn                    jbjkjb&lt;BR /&gt;
Bvc_tgg_hgh3    bvbmnm             bnbn,m&lt;BR /&gt;
Cdd_Tcc_Ydd         cfghg                      ghghkj&lt;BR /&gt;
D1                          aafdfdf                    tgkgj&lt;BR /&gt;
E                           dsfdfg                     cvcbb&lt;BR /&gt;
Ftt_Tff_Ygg_1       fcxcvbvb                   ghvgnbvn&lt;BR /&gt;
Ftt_Tff_Ygg_2       vbbnbb                     bvbbnnb&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Table 2:&lt;/STRONG&gt;&lt;BR /&gt;
&lt;STRONG&gt;Column1           Column5   Column6&lt;/STRONG&gt;&lt;BR /&gt;
xyz_sss_*            vbvnb b               cvgbvb b&lt;BR /&gt;
Bvc_tgg_hgh*      bvnbnbb          vbnbb&lt;BR /&gt;
Cdd_Tcc_Ydd           bvbbnm        kkjkljlk&lt;BR /&gt;
D*                            sdffg             hjjhmn&lt;BR /&gt;
E                             hvhjvb                hvbhjm&lt;BR /&gt;
Ftt_Tff_Ygg*              fdgfgh                hvbnvmn&lt;/P&gt;

&lt;P&gt;Please help in joining Table:1 to Table:2 taking Column1 as a common field where for example xyz_sss_12 should map to xyz_sss_&lt;EM&gt;,  Bvc_tgg_hgh1 and Bvc_tgg_hgh2 and Bvc_tgg_hgh3 should map to Bvc_tgg_hgh&lt;/EM&gt; and likewise. A prompt response will be highly appreciated!&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 09:39:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-2-tables-for-matching-field-values/m-p/240902#M71607</guid>
      <dc:creator>anshumandas</dc:creator>
      <dc:date>2020-09-29T09:39:41Z</dc:date>
    </item>
    <item>
      <title>Re: Join 2 tables for matching field values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-2-tables-for-matching-field-values/m-p/240903#M71608</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;search source=table1 OR source=table2 | rex field=column1 "(?&amp;lt;newid&amp;gt;[A-Za-z_]+)" | eval newid=if(source=table2, column1, newid) | stats list(column1) as olddolvalues by newid
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 06 May 2016 22:33:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-2-tables-for-matching-field-values/m-p/240903#M71608</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-05-06T22:33:15Z</dc:date>
    </item>
    <item>
      <title>Re: Join 2 tables for matching field values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-2-tables-for-matching-field-values/m-p/240904#M71609</link>
      <description>&lt;P&gt;Hi Sundaresh,&lt;/P&gt;

&lt;P&gt;I should have probably been more precise. I definitely need to use join the 2 tables first using the 1 field (Column1) for both the tables and I need to extract some more columns from both the tables to perform the calculation based on the extracted field. Where I am stuck is to extract the field values from Table-2 which has asterix at the end where as Table 1 has no asterix and instead has sub-processes. for example Table-1 has something like abc_xyz_pqr_1, abc_xyz_pqr_2, abc_xyz_pqr_3 or abc_xyz_pqr1, abc_xyz_pqr2, abc_xyz_pqr3 whereas Table-2 has only parent processes say only abc_xyz_pqr_&lt;EM&gt;(asterix) or abc_xyz_pqr&lt;/EM&gt;(asterix). Also point to remember is we need to join Table-1--&amp;gt; Table-2 for the intricacy of the requirement that I have.&lt;/P&gt;

&lt;P&gt;Kindly help if you can!&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 09:39:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-2-tables-for-matching-field-values/m-p/240904#M71609</guid>
      <dc:creator>anshumandas</dc:creator>
      <dc:date>2020-09-29T09:39:43Z</dc:date>
    </item>
    <item>
      <title>Re: Join 2 tables for matching field values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-2-tables-for-matching-field-values/m-p/240905#M71610</link>
      <description>&lt;P&gt;Have you tried the Out-Of-The-Box join? as described at &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Join"&gt;join&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 06 May 2016 23:07:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-2-tables-for-matching-field-values/m-p/240905#M71610</guid>
      <dc:creator>ddrillic</dc:creator>
      <dc:date>2016-05-06T23:07:13Z</dc:date>
    </item>
    <item>
      <title>Re: Join 2 tables for matching field values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-2-tables-for-matching-field-values/m-p/240906#M71611</link>
      <description>&lt;P&gt;@anshumandas,&lt;/P&gt;

&lt;P&gt;The asterix will also be ignore by the regex, so you will have two matching values (everything to the left of either digit or asterix). Now, to join these, you could do the &lt;CODE&gt;join&lt;/CODE&gt; command. Something like this might work&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source=table1 | rex field=column1 "(?&amp;lt;newid&amp;gt;[A-Za-z_]+)" | join newid [search source=table1 | rex field=column1 "(?&amp;lt;newid&amp;gt;[A-Za-z_]+)" | table newid ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can look at the online documentation for the &lt;CODE&gt;join&lt;/CODE&gt; command and adjust the query to meet your needs. &lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Join"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Join&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;I should caution you though, the &lt;CODE&gt;join&lt;/CODE&gt; command has limitation and is a slow process. There may be more efficient ways to get you the final result, if you can share more details on the data and result.&lt;/P&gt;</description>
      <pubDate>Fri, 06 May 2016 23:38:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-2-tables-for-matching-field-values/m-p/240906#M71611</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-05-06T23:38:46Z</dc:date>
    </item>
    <item>
      <title>Re: Join 2 tables for matching field values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-2-tables-for-matching-field-values/m-p/240907#M71612</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|inputcsv table1 | appendpipe [|inputcsv table2] | eval joiner = Column1 | rex field=joiner mode=sed "s/_[^_]+$//" | stats values(*) AS * BY joiner
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Or maybe this (depending on source of data)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source=table1 OR source=table2 | eval joiner = Column1 | rex field=joiner mode=sed "s/_[^_]+$//" | stats values(*) AS * BY joiner
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 07 May 2016 13:02:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-2-tables-for-matching-field-values/m-p/240907#M71612</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2016-05-07T13:02:09Z</dc:date>
    </item>
    <item>
      <title>Re: Join 2 tables for matching field values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-2-tables-for-matching-field-values/m-p/240908#M71613</link>
      <description>&lt;P&gt;@woodcock, this is a novel approach and absolutely brilliant... been trying to enrich data on the fly forEVER and nothing works the way I want it to, but I knew I was missing something.  Lookups, joins, subsearches, appendcols, append and summary indexing have all failed me, but your answer came through.  I guess I should've found it sooner.  Anyway, I gave you a ton of rep points, in case you're still around.&lt;/P&gt;

&lt;P&gt;Incidentally, it also works for mixing data types (lookup &amp;amp; indexed datas).  For instance:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|inputlookup things.csv | eval joiner = upper(names) | append [search index=blegh sourcetype=blargh | eval joiner=upper(names) |  fields  stuff names thing1 thing2 thing3] | stats values(*) AS * by joiner
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Works like a champ.  Thanks again!&lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2016 22:51:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-2-tables-for-matching-field-values/m-p/240908#M71613</guid>
      <dc:creator>proletariat99</dc:creator>
      <dc:date>2016-10-18T22:51:06Z</dc:date>
    </item>
    <item>
      <title>Re: Join 2 tables for matching field values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-2-tables-for-matching-field-values/m-p/240909#M71614</link>
      <description>&lt;P&gt;Yes, &lt;CODE&gt;| stats values(*) AS * BY joiner&lt;/CODE&gt; is SUPER powerful and can do inner/outer/left/right joins very flexibly and efficiently.   Please do click &lt;CODE&gt;Accept&lt;/CODE&gt; to close the answer and clearly indicate a solution to others who may be having the same problem and are looking for a working solution.&lt;/P&gt;

&lt;P&gt;BTW, your &lt;CODE&gt;lookup&lt;/CODE&gt; search suffers from the 50.5K  subsearch limit.  If you do it this way, it is unlimited:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=blegh sourcetype=blargh | eval joiner=upper(names) | fields  stuff names thing1 thing2 thing3
| appendpipe [|inputlookup things.csv | eval joiner = upper(names)]
| stats values(*) AS * BY joiner
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 02 Nov 2016 18:53:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-2-tables-for-matching-field-values/m-p/240909#M71614</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2016-11-02T18:53:45Z</dc:date>
    </item>
  </channel>
</rss>

