<?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: How to do an outer join on two tables with two fields? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-do-an-outer-join-on-two-tables-with-two-fields/m-p/483937#M135480</link>
    <description>&lt;P&gt;did you try &lt;CODE&gt;| append&lt;/CODE&gt; or &lt;CODE&gt;| appendcols&lt;/CODE&gt; commands?&lt;/P&gt;</description>
    <pubDate>Tue, 28 Apr 2020 15:47:51 GMT</pubDate>
    <dc:creator>adonio</dc:creator>
    <dc:date>2020-04-28T15:47:51Z</dc:date>
    <item>
      <title>How to do an outer join on two tables with two fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-do-an-outer-join-on-two-tables-with-two-fields/m-p/483936#M135479</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
I'm wondering if it's possible to do an outer/left join two tables on two fields.  I have two indexes with the following data:&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Index1:&lt;/STRONG&gt;&lt;BR /&gt;
col1            col2&lt;BR /&gt;
123     abc&lt;BR /&gt;
456     def&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Index2:&lt;/STRONG&gt;&lt;BR /&gt;
col1            col2            col3&lt;BR /&gt;
123     abc     xyz&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Desired results:&lt;/STRONG&gt;&lt;BR /&gt;
col1            col2            col3&lt;BR /&gt;
123     abc     xyz&lt;BR /&gt;
456     def&lt;/P&gt;

&lt;P&gt;Here's my search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=index1
|join type=outer col1, col2
[search index=index2
|fields col1, col2, col3]
|table col1, col2, col3
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The results I get are inconsistent.  It seems almost as if Splunk is going the outer join on the two columns independently, so I get more results than I need.  If I remove the "type=outer", making it an inner join, I get the below results, so I know the join works for the inner:&lt;BR /&gt;
&lt;STRONG&gt;col1          col2            col3&lt;BR /&gt;
123     abc     xyz&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
AP&lt;/P&gt;</description>
      <pubDate>Tue, 28 Apr 2020 15:24:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-do-an-outer-join-on-two-tables-with-two-fields/m-p/483936#M135479</guid>
      <dc:creator>apiprek2</dc:creator>
      <dc:date>2020-04-28T15:24:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to do an outer join on two tables with two fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-do-an-outer-join-on-two-tables-with-two-fields/m-p/483937#M135480</link>
      <description>&lt;P&gt;did you try &lt;CODE&gt;| append&lt;/CODE&gt; or &lt;CODE&gt;| appendcols&lt;/CODE&gt; commands?&lt;/P&gt;</description>
      <pubDate>Tue, 28 Apr 2020 15:47:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-do-an-outer-join-on-two-tables-with-two-fields/m-p/483937#M135480</guid>
      <dc:creator>adonio</dc:creator>
      <dc:date>2020-04-28T15:47:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to do an outer join on two tables with two fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-do-an-outer-join-on-two-tables-with-two-fields/m-p/483938#M135481</link>
      <description>&lt;P&gt;From the fact that you're talking about outer joins, you are coming from an SQL background, so READ THIS FIRST: &lt;/P&gt;

&lt;P&gt;&lt;A href="https://answers.splunk.com/answers/561130/how-to-join-two-tables-where-the-key-is-named-diff.html"&gt;https://answers.splunk.com/answers/561130/how-to-join-two-tables-where-the-key-is-named-diff.html&lt;/A&gt;&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;The general answer is called "splunk soup" or "splunk stew".  You throw all the records and fields you want together in the pot and then stir until they come apart the way you want.&lt;/P&gt;

&lt;P&gt;Here's generic pseudocode for that method...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  ((filters identifying events of type A) OR (filters identifying events of type B)) 
 | fields ... the list of every field that you need from either type A or B... 
 | eval joinfield = case(expression to detect type A, functions(to(transform(events, of, type, A))), 
                         expression to detect type B, functions(to(transform(events, of, type, A)))) 
 | stats values(field1) as field1 values(... as fieldN by joinfield
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;HR /&gt;

&lt;P&gt;Then you can also look at this one.  If you still have any questions, then please feel free to ask via a comment here.&lt;/P&gt;

&lt;P&gt;&lt;A href="https://answers.splunk.com/answers/816615/how-to-search-for-a-value-in-multiple-fields.html"&gt;https://answers.splunk.com/answers/816615/how-to-search-for-a-value-in-multiple-fields.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Apr 2020 15:51:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-do-an-outer-join-on-two-tables-with-two-fields/m-p/483938#M135481</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2020-04-28T15:51:59Z</dc:date>
    </item>
  </channel>
</rss>

