<?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: sql left join query in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/sql-left-join-query/m-p/86809#M22158</link>
    <description>&lt;P&gt;I checked that page.  Unfortunately, I can't tell how to access the columns on both sides of the join at the same time in order to subtract the after value from the before value.&lt;/P&gt;</description>
    <pubDate>Fri, 22 Apr 2011 13:48:54 GMT</pubDate>
    <dc:creator>bbrooks_sciques</dc:creator>
    <dc:date>2011-04-22T13:48:54Z</dc:date>
    <item>
      <title>sql left join query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/sql-left-join-query/m-p/86807#M22156</link>
      <description>&lt;P&gt;I'm trying to do something similar the following in sql:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;select after.ne - before.ne, after.bpdlr - before.bpdlr from tablea after left outer join tableb before on (a.hash = b.hash) where a.timestamp='2011-04-21 12:00:00' and b.timestamp='2011-04-21 11:00:00'&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Any suggestions?&lt;/P&gt;</description>
      <pubDate>Thu, 21 Apr 2011 19:55:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/sql-left-join-query/m-p/86807#M22156</guid>
      <dc:creator>bbrooks_sciques</dc:creator>
      <dc:date>2011-04-21T19:55:56Z</dc:date>
    </item>
    <item>
      <title>Re: sql left join query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/sql-left-join-query/m-p/86808#M22157</link>
      <description>&lt;P&gt;i'm not a strong sql user, but this might be helpful to you:&lt;/P&gt;

&lt;P&gt;&lt;A href="http://www.innovato.com/splunk/SQLSplunk.html"&gt;http://www.innovato.com/splunk/SQLSplunk.html&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;not an official Splunk doc, but super useful!&lt;/P&gt;</description>
      <pubDate>Thu, 21 Apr 2011 21:02:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/sql-left-join-query/m-p/86808#M22157</guid>
      <dc:creator>piebob</dc:creator>
      <dc:date>2011-04-21T21:02:45Z</dc:date>
    </item>
    <item>
      <title>Re: sql left join query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/sql-left-join-query/m-p/86809#M22158</link>
      <description>&lt;P&gt;I checked that page.  Unfortunately, I can't tell how to access the columns on both sides of the join at the same time in order to subtract the after value from the before value.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Apr 2011 13:48:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/sql-left-join-query/m-p/86809#M22158</guid>
      <dc:creator>bbrooks_sciques</dc:creator>
      <dc:date>2011-04-22T13:48:54Z</dc:date>
    </item>
    <item>
      <title>Re: sql left join query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/sql-left-join-query/m-p/86810#M22159</link>
      <description>&lt;P&gt;This topic comes up so regularly that I think someone needs to make a big poster or flowchart.   At the top is "I'm pretty sure I need to use some kind of join",  and almost all the outcomes involve using stats or transaction, or subsearches.  and some tiny slice of the outcomes would actually use splunk's &lt;CODE&gt;join&lt;/CODE&gt; command, or it's cousins &lt;CODE&gt;append&lt;/CODE&gt; and &lt;CODE&gt;appendcols&lt;/CODE&gt;.  &lt;/P&gt;

&lt;P&gt;The &lt;A href="http://www.innovato.com/splunk/SQLSplunk.html----"&gt;Splunk for SQL users&lt;/A&gt; page is a really great resource, but unfortunately it simply says that the equivalent of a SQL join is the splunk &lt;CODE&gt;join&lt;/CODE&gt; command and while that's technically true, in a practical sense it doesn't get people where they're trying to go. &lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;You need join cause you have two disparate sets of events, and they share some kind of 'id' field,  and you want to join on that field.  makes sense. &lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;OK, forget the &lt;CODE&gt;join&lt;/CODE&gt; command for a while.  We'll come back to it. You should first look at stats: &lt;/P&gt;

&lt;P&gt;( &lt;SEARCH1&gt; ) OR &lt;SEARCH2&gt; by yourId&lt;/SEARCH2&gt;&lt;/SEARCH1&gt;&lt;/P&gt;&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;The important part is the &lt;B&gt;by yourId&lt;/B&gt;. The idea is to let Splunk pull the events off disk in a jumble, and then let the stats command sort it all out for you.  the 'various operations' can include 'avg', 'max',  'perc95', 'first', 'last',  'values', 'list'..   etc..    (In the case of the multivalued operations like 'list' and 'values', certain splunk search commands like &lt;CODE&gt;mvexpand&lt;/CODE&gt; &lt;EM&gt;can&lt;/EM&gt; be useful after the stats.  However if you're using them a lot you're usually overthinking something again. )&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;&lt;P&gt;In some more complex cases, like where there are &lt;CODE&gt;rex&lt;/CODE&gt; and &lt;CODE&gt;eval&lt;/CODE&gt; in the two searches, it seems like you cannot combine the two searches into a simple disjunction (foo OR Bar).  However you usually can do it even in these cases, with a little &lt;CODE&gt;eval&lt;/CODE&gt; command and a little &lt;CODE&gt;searchmatch&lt;/CODE&gt;.  Search for eval and searchmatch on answers and you'll see some interesting cases. &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;In some cases where one of the search result sets is extremely small, the other is extremely large, and what you want at the end of the day is a small intersection,   it's often a good idea to look at subsearches.   The idea here is to search for one set of events,  get a list of some distinct 'id' values, turn that around and search on it in a giant (id=foo OR id=bar OR id=baz ....)  term against some other data. &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;If you dont think you have fallen into one of the above scenarios, you &lt;EM&gt;may&lt;/EM&gt; actually be one of the use cases that only &lt;CODE&gt;append&lt;/CODE&gt; or &lt;CODE&gt;join&lt;/CODE&gt; or &lt;CODE&gt;appendcols&lt;/CODE&gt; can solve.   However honestly you can probably still do it with stats, and if you can do it with stats you &lt;EM&gt;should&lt;/EM&gt;.  Searching for large result sets in any kind of subsearch is always going to be a little slow and subject to subtle problems it might take a long time to even see.  &lt;/P&gt;&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;There are a lot of great questions and answers on the answers site.  (Where you can find me saying the same thing over and over and over again) &lt;/P&gt;

&lt;P&gt;&lt;A href="http://splunk-base.splunk.com/answers/10377/jointransaction-with-field-comparison-operators"&gt;http://splunk-base.splunk.com/answers/10377/jointransaction-with-field-comparison-operators&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Unfortunately the search functionality on answers returns pretty poor results.  The good news is that Google can pull them out for you quite easily: &lt;/P&gt;

&lt;P&gt;&lt;A href="http://www.google.com/search?rlz=1C1CHFX_enUS396US396&amp;amp;sourceid=chrome&amp;amp;ie=UTF-8&amp;amp;q=splunk+transaction+stats+join"&gt;http://www.google.com/search?rlz=1C1CHFX_enUS396US396&amp;amp;sourceid=chrome&amp;amp;ie=UTF-8&amp;amp;q=splunk+transaction+stats+join&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;&lt;A href="http://splunk-base.splunk.com/answers/22681/newbie-splunk-equivalent-of-natural-join"&gt;http://splunk-base.splunk.com/answers/22681/newbie-splunk-equivalent-of-natural-join&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;-&lt;/P&gt;</description>
      <pubDate>Fri, 22 Apr 2011 18:30:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/sql-left-join-query/m-p/86810#M22159</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2011-04-22T18:30:17Z</dc:date>
    </item>
    <item>
      <title>Re: sql left join query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/sql-left-join-query/m-p/86811#M22160</link>
      <description>&lt;P&gt;Can you add the details about the splunk search or searches involved?   That will help us guide you to the best approach, between using 'stats', 'transaction', 'join' etc...&lt;/P&gt;</description>
      <pubDate>Fri, 22 Apr 2011 18:31:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/sql-left-join-query/m-p/86811#M22160</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2011-04-22T18:31:19Z</dc:date>
    </item>
  </channel>
</rss>

