<?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 Subsearch like correlated subquery in SQL in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-like-correlated-subquery-in-SQL/m-p/9532#M158</link>
    <description>&lt;P&gt;Is it possible with subsearch to pass a list of search results to the outside search? similar to a SQL correlated subquery?&lt;/P&gt;

&lt;P&gt;Background:  I have an event that lists an ID and a ReferenceID.  The ReferenceID will be a previous ID.  Often however, there has been several days, if not weeks between the original ID and the ReferenceID.  This makes a Transaction search ineffective for this query.&lt;/P&gt;

&lt;P&gt;What I'd like to do, is to obtain a list of ReferenceIDs that match some criteria (quick) and then pass each of those into an outer search, so the outer search runs for each of the results returned from the inner search (not the combined results of the inner search).  Is this possible?&lt;/P&gt;</description>
    <pubDate>Sat, 30 Jan 2010 03:58:16 GMT</pubDate>
    <dc:creator>Yancy</dc:creator>
    <dc:date>2010-01-30T03:58:16Z</dc:date>
    <item>
      <title>Subsearch like correlated subquery in SQL</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-like-correlated-subquery-in-SQL/m-p/9532#M158</link>
      <description>&lt;P&gt;Is it possible with subsearch to pass a list of search results to the outside search? similar to a SQL correlated subquery?&lt;/P&gt;

&lt;P&gt;Background:  I have an event that lists an ID and a ReferenceID.  The ReferenceID will be a previous ID.  Often however, there has been several days, if not weeks between the original ID and the ReferenceID.  This makes a Transaction search ineffective for this query.&lt;/P&gt;

&lt;P&gt;What I'd like to do, is to obtain a list of ReferenceIDs that match some criteria (quick) and then pass each of those into an outer search, so the outer search runs for each of the results returned from the inner search (not the combined results of the inner search).  Is this possible?&lt;/P&gt;</description>
      <pubDate>Sat, 30 Jan 2010 03:58:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subsearch-like-correlated-subquery-in-SQL/m-p/9532#M158</guid>
      <dc:creator>Yancy</dc:creator>
      <dc:date>2010-01-30T03:58:16Z</dc:date>
    </item>
    <item>
      <title>Re: Subsearch like correlated subquery in SQL</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-like-correlated-subquery-in-SQL/m-p/9533#M159</link>
      <description>&lt;P&gt;Hi Yancy,&lt;/P&gt;

&lt;P&gt;This is possible.  Something to note about subsearches is the format of what is passed from the inner search to the outer search is important.  If you are looking to pass a list of ReferenceIDs, then use the &lt;CODE&gt;fields&lt;/CODE&gt; command at the end of your inner search.  Otherwise, Splunk will by default pass the events themselves to the outer search.&lt;/P&gt;

&lt;P&gt;In pseudo search, your use case will look something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... &amp;lt;my outer search&amp;gt; [search ReferenceID=abc | fields + ReferenceID]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you post some sample data, we can help you construct the specific query.&lt;/P&gt;</description>
      <pubDate>Sat, 30 Jan 2010 05:15:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subsearch-like-correlated-subquery-in-SQL/m-p/9533#M159</guid>
      <dc:creator>hulahoop</dc:creator>
      <dc:date>2010-01-30T05:15:29Z</dc:date>
    </item>
    <item>
      <title>Re: Subsearch like correlated subquery in SQL</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-like-correlated-subquery-in-SQL/m-p/9534#M160</link>
      <description>&lt;P&gt;It is possible to run an outer search the way you want with the &lt;CODE&gt;map&lt;/CODE&gt; command, one time over each inner search result. However, this is extremely inefficient in Splunk, and it is likely that there is a much better way to do it using a subsearch as described by hulahoop. The difference is that you'll have to execute &lt;EM&gt;n&lt;/EM&gt;+1 searches (where N is the number of inner search results) instead of 2 searches. To a first approximation, this will take (&lt;EM&gt;n&lt;/EM&gt;+1)/2 times as long.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Feb 2010 16:14:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subsearch-like-correlated-subquery-in-SQL/m-p/9534#M160</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2010-02-01T16:14:49Z</dc:date>
    </item>
    <item>
      <title>Re: Subsearch like correlated subquery in SQL</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subsearch-like-correlated-subquery-in-SQL/m-p/9535#M161</link>
      <description>&lt;P&gt;&lt;A href="http://www.innovato.com/splunk/SQLSplunk.html" rel="nofollow"&gt;Splunk For SQL Users&lt;/A&gt; is also a good resource for this type of question.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Apr 2010 02:43:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subsearch-like-correlated-subquery-in-SQL/m-p/9535#M161</guid>
      <dc:creator>Yancy</dc:creator>
      <dc:date>2010-04-14T02:43:11Z</dc:date>
    </item>
  </channel>
</rss>

