<?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: Does Splunk have an equivalent to SQL's IN () construct? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Does-Splunk-have-an-equivalent-to-SQL-s-IN-construct/m-p/35525#M7797</link>
    <description>&lt;P&gt;And note that &lt;CODE&gt;inputlookup&lt;/CODE&gt; is one way to populate the subsearch clause. You can use any valid Splunk search in the subsearch, just as you can use any SQL statement in a subselect.&lt;/P&gt;</description>
    <pubDate>Tue, 28 Jun 2011 03:22:21 GMT</pubDate>
    <dc:creator>gkanapathy</dc:creator>
    <dc:date>2011-06-28T03:22:21Z</dc:date>
    <item>
      <title>Does Splunk have an equivalent to SQL's IN () construct?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Does-Splunk-have-an-equivalent-to-SQL-s-IN-construct/m-p/35522#M7794</link>
      <description>&lt;P&gt;I have an analyst who wants to find logs where the value of a field is in a list of values. In SQL we can do this by saying:&lt;/P&gt;

&lt;P&gt;SELECT * FROM table WHERE field IN (tuple, of, values);&lt;/P&gt;

&lt;P&gt;Is there an easy, throw-away way to do this in Splunk?&lt;/P&gt;

&lt;P&gt;EDIT: This list is too long to specify with a string of OR clauses; I'm looking for something a little neater than that…&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jun 2011 00:22:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Does-Splunk-have-an-equivalent-to-SQL-s-IN-construct/m-p/35522#M7794</guid>
      <dc:creator>andrewdotnich</dc:creator>
      <dc:date>2011-06-28T00:22:55Z</dc:date>
    </item>
    <item>
      <title>Re: Does Splunk have an equivalent to SQL's IN () construct?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Does-Splunk-have-an-equivalent-to-SQL-s-IN-construct/m-p/35523#M7795</link>
      <description>&lt;P&gt;1) You could create a lookup (think a big csv file) where each row is one of the values in your tuple. &lt;BR /&gt;
The lookup would have to have two columns even though in such a simple case the second one feels redundant.  &lt;/P&gt;

&lt;P&gt;in this case lets say wegive it columns called 'value'  and 'weirdness' as your columns. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;your search&amp;gt; | lookup mylookupname fieldName | where weirdness=1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;A href="http://www.splunk.com/base/Documentation/4.2.2/User/Fieldlookupstutorial"&gt;http://www.splunk.com/base/Documentation/4.2.2/User/Fieldlookupstutorial&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;&lt;A href="http://www.splunk.com/base/Documentation/latest/SearchReference/Lookup"&gt;http://www.splunk.com/base/Documentation/latest/SearchReference/Lookup&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;2) If the events that you're trying to match on are a tiny subset of the main events, there's another similar way that can be much more efficient.   That is to use the inputlookup command within a subsearch.  Essentially you're doing that gigantic OR search, butin an automated way&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;your search&amp;gt; [ inputlookup mylookupname | fields myfieldname ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;A href="http://www.splunk.com/base/Documentation/4.2.2/User/HowSubsearchesWork"&gt;http://www.splunk.com/base/Documentation/4.2.2/User/HowSubsearchesWork&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jun 2011 00:39:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Does-Splunk-have-an-equivalent-to-SQL-s-IN-construct/m-p/35523#M7795</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2011-06-28T00:39:45Z</dc:date>
    </item>
    <item>
      <title>Re: Does Splunk have an equivalent to SQL's IN () construct?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Does-Splunk-have-an-equivalent-to-SQL-s-IN-construct/m-p/35524#M7796</link>
      <description>&lt;P&gt;Edited some. A subsearch within the base search is exactly the equivalent of a subselect used in an &lt;CODE&gt;IN&lt;/CODE&gt; clause in SQL.&lt;/P&gt;

&lt;P&gt;Also, the size of the list (the &lt;CODE&gt;IN&lt;/CODE&gt; clause, or the size of &lt;CODE&gt;mylookupname&lt;/CODE&gt; file) can be 10,000 items in size, which is larger than the allowed size of an &lt;CODE&gt;IN&lt;/CODE&gt; clause in many SQL databases.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jun 2011 03:21:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Does-Splunk-have-an-equivalent-to-SQL-s-IN-construct/m-p/35524#M7796</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2011-06-28T03:21:18Z</dc:date>
    </item>
    <item>
      <title>Re: Does Splunk have an equivalent to SQL's IN () construct?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Does-Splunk-have-an-equivalent-to-SQL-s-IN-construct/m-p/35525#M7797</link>
      <description>&lt;P&gt;And note that &lt;CODE&gt;inputlookup&lt;/CODE&gt; is one way to populate the subsearch clause. You can use any valid Splunk search in the subsearch, just as you can use any SQL statement in a subselect.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jun 2011 03:22:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Does-Splunk-have-an-equivalent-to-SQL-s-IN-construct/m-p/35525#M7797</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2011-06-28T03:22:21Z</dc:date>
    </item>
    <item>
      <title>Re: Does Splunk have an equivalent to SQL's IN () construct?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Does-Splunk-have-an-equivalent-to-SQL-s-IN-construct/m-p/35526#M7798</link>
      <description>&lt;P&gt;Another idea:  Use regex&lt;/P&gt;

&lt;P&gt;| regex field="^(a|b|c|d|e|f|g)$"&lt;/P&gt;

&lt;P&gt;A bit clunky, but better than tons of ORs. &lt;/P&gt;</description>
      <pubDate>Sat, 11 Feb 2017 05:10:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Does-Splunk-have-an-equivalent-to-SQL-s-IN-construct/m-p/35526#M7798</guid>
      <dc:creator>rstitt</dc:creator>
      <dc:date>2017-02-11T05:10:28Z</dc:date>
    </item>
    <item>
      <title>Re: Does Splunk have an equivalent to SQL's IN () construct?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Does-Splunk-have-an-equivalent-to-SQL-s-IN-construct/m-p/35527#M7799</link>
      <description>&lt;P&gt;In Splunk 6.6 there is a new feature now that you CAN use IN(). Below is a link to the doc on it.&lt;/P&gt;

&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/SplunkCloud/6.6.0/SearchReference/Search#Multiple_field-value_comparisons_with_the_IN_operator"&gt;IN() operator in search&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2017 19:49:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Does-Splunk-have-an-equivalent-to-SQL-s-IN-construct/m-p/35527#M7799</guid>
      <dc:creator>MattZerfas</dc:creator>
      <dc:date>2017-09-05T19:49:32Z</dc:date>
    </item>
  </channel>
</rss>

