<?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 JOIN the same table? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-JOIN-the-same-table/m-p/360634#M106590</link>
    <description>&lt;P&gt;I disagree.  I am sure that the &lt;CODE&gt;A&lt;/CODE&gt; values are to be correlated and also the &lt;CODE&gt;B&lt;/CODE&gt; values.  That is half the point.&lt;/P&gt;</description>
    <pubDate>Mon, 20 Mar 2017 16:37:32 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2017-03-20T16:37:32Z</dc:date>
    <item>
      <title>How to JOIN the same table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-JOIN-the-same-table/m-p/360629#M106585</link>
      <description>&lt;P&gt;Hi, i've this table&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;R      VIP            state
R1     1.1.1.1        Master
R2     1.1.1.1        Backup
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want to join the table so the result will be as follows&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;R_A      R_B          VIP             state_A         state_B
R1       R2           1.1.1.1         Master          Backup
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If i'm using VIP as the ID for join, R1 can join with him self and also R2, this is the result&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;R_A      R_B          VIP             state_A         state_B
R1       R1           1.1.1.1         Master          Master
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How to avoid this happen? so the join will happen only if some value on the field is not the same&lt;/P&gt;</description>
      <pubDate>Sat, 18 Mar 2017 06:18:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-JOIN-the-same-table/m-p/360629#M106585</guid>
      <dc:creator>pakerwe</dc:creator>
      <dc:date>2017-03-18T06:18:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to JOIN the same table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-JOIN-the-same-table/m-p/360630#M106586</link>
      <description>&lt;P&gt;This fakes your data:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval raw="R1     1.1.1.1        Master::R2     1.1.1.1        Backup"
| makemv delim="::" raw
| mvexpand raw
| rex field=raw "(?&amp;lt;R&amp;gt;\S+)\s+(?&amp;lt;VIP&amp;gt;\S+)\s+(?&amp;lt;state&amp;gt;.+)"
| table R VIP state
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is your solution:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats list(*) AS * first(R) AS R_A last(R) AS R_B first(state) AS state_A last(state) AS state_B BY VIP
| rename COMMENT AS "eval R_A=mvindex(R,0), R_B=mvindex(R,1), state_A=mvindex(state,0), state_B=mvindex(state,1)"
| table R_A R_B VIP state_A state_B
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 19 Mar 2017 02:45:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-JOIN-the-same-table/m-p/360630#M106586</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-03-19T02:45:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to JOIN the same table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-JOIN-the-same-table/m-p/360631#M106587</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/1406"&gt;@woodcock&lt;/a&gt;... After posting my answer I realized you had already answered this with a better query than what I was suggesting (so I deleted mine). However, I felt that &lt;STRONG&gt;values&lt;/STRONG&gt;() should be used instead of &lt;STRONG&gt;list&lt;/STRONG&gt;() to get only unique values of  R and state, only to cover scenario where data might contain multiple occurrences. However, &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/12288"&gt;@pakerwe&lt;/a&gt; can confirm the same. Also we would need to know whether there are only two possible values like R_A, R_B or can there be more like R_C for R3 possible?&lt;/P&gt;

&lt;P&gt;Also on an irrelevant note, following is another way to mock the data:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval R="R1" 
| eval VIP="1.1.1.1" 
| eval state="master" 
  | append 
  [ | makeresults 
    | eval R="R2" 
    | eval VIP="1.1.1.1" 
    | eval state="backup"]
| table R VIP state
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Sep 2020 13:18:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-JOIN-the-same-table/m-p/360631#M106587</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2020-09-29T13:18:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to JOIN the same table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-JOIN-the-same-table/m-p/360632#M106588</link>
      <description>&lt;P&gt;You must not use &lt;CODE&gt;values&lt;/CODE&gt; because it resorts the order alphabetically and we must retain the alignment/correlation of the values between the &lt;CODE&gt;R&lt;/CODE&gt; and &lt;CODE&gt;state&lt;/CODE&gt; fields; this is why I deliberately used &lt;CODE&gt;list&lt;/CODE&gt;.  Also, I modified the answer to eliminate the necessity of multi-valued fields entirely.&lt;/P&gt;</description>
      <pubDate>Sun, 19 Mar 2017 19:55:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-JOIN-the-same-table/m-p/360632#M106588</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-03-19T19:55:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to JOIN the same table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-JOIN-the-same-table/m-p/360633#M106589</link>
      <description>&lt;P&gt;@woodcock...In this case all values are required to be presented in the single row, which means correlation is actually only required between VIP and remaining two fields and not within R and state. However, again @pakerwe should confirm the data and requirement.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Mar 2017 04:15:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-JOIN-the-same-table/m-p/360633#M106589</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-03-20T04:15:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to JOIN the same table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-JOIN-the-same-table/m-p/360634#M106590</link>
      <description>&lt;P&gt;I disagree.  I am sure that the &lt;CODE&gt;A&lt;/CODE&gt; values are to be correlated and also the &lt;CODE&gt;B&lt;/CODE&gt; values.  That is half the point.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Mar 2017 16:37:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-JOIN-the-same-table/m-p/360634#M106590</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-03-20T16:37:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to JOIN the same table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-JOIN-the-same-table/m-p/360635#M106591</link>
      <description>&lt;P&gt;That is some crazy feature there with the rename command. Is there any documentation on that? &lt;/P&gt;</description>
      <pubDate>Mon, 20 Mar 2017 17:44:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-JOIN-the-same-table/m-p/360635#M106591</guid>
      <dc:creator>jplumsdaine22</dc:creator>
      <dc:date>2017-03-20T17:44:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to JOIN the same table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-JOIN-the-same-table/m-p/360636#M106592</link>
      <description>&lt;P&gt;&lt;A href="https://answers.splunk.com/answers/48865/add-a-comment-to-a-search.html"&gt;https://answers.splunk.com/answers/48865/add-a-comment-to-a-search.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Mar 2017 18:19:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-JOIN-the-same-table/m-p/360636#M106592</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-03-20T18:19:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to JOIN the same table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-JOIN-the-same-table/m-p/360637#M106593</link>
      <description>&lt;P&gt;seriously weird.  And it has identical results to removing the &lt;CODE&gt;"rename COMMENT AS "&lt;/CODE&gt;  and the end quote, so what's the point?&lt;/P&gt;</description>
      <pubDate>Mon, 20 Mar 2017 18:33:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-JOIN-the-same-table/m-p/360637#M106593</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-03-20T18:33:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to JOIN the same table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-JOIN-the-same-table/m-p/360638#M106594</link>
      <description>&lt;P&gt;It is the previous code, which does work.  It is a comment, that is all.  The longer the search, the more important it is to comment your code.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Mar 2017 20:22:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-JOIN-the-same-table/m-p/360638#M106594</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-03-20T20:22:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to JOIN the same table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-JOIN-the-same-table/m-p/360639#M106595</link>
      <description>&lt;P&gt;oh derp I thought the eval statement was getting executed. lol never mind&lt;/P&gt;</description>
      <pubDate>Tue, 21 Mar 2017 13:08:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-JOIN-the-same-table/m-p/360639#M106595</guid>
      <dc:creator>jplumsdaine22</dc:creator>
      <dc:date>2017-03-21T13:08:18Z</dc:date>
    </item>
  </channel>
</rss>

