<?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: Splunks equivalent to the SQL &amp;quot;IN&amp;quot; ()  function in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Splunks-equivalent-to-the-SQL-quot-IN-quot-function/m-p/44395#M179197</link>
    <description>&lt;P&gt;We can all celebrate v6.6.1:&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/SplunkCloud/6.6.1/ReleaseNotes/NewSplunkCloudFeatures"&gt;http://docs.splunk.com/Documentation/SplunkCloud/6.6.1/ReleaseNotes/NewSplunkCloudFeatures&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Because this:&lt;BR /&gt;
New SQL-like IN SPL operator    New SPL operator that acts as a shorthand for multiple disjunctions of one field.   See Comparison and Conditional functions and search in the Search Reference manual.&lt;/P&gt;

&lt;P&gt;So this:&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/SplunkCloud/6.6.1/SearchReference/ConditionalFunctions#in.28VALUE-LIST.29"&gt;http://docs.splunk.com/Documentation/SplunkCloud/6.6.1/SearchReference/ConditionalFunctions#in.28VALUE-LIST.29&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;And this:&lt;BR /&gt;
You can use this function with the eval, fieldformat, and where commands, and as part of eval expressions with other commands.&lt;BR /&gt;
There is also an IN operator that is similar to the in(VALUE-LIST) function that you can use with the search and tstats commands.&lt;BR /&gt;
The following syntax is supported:&lt;BR /&gt;
...| where in(field,"value1","value2", ...)&lt;BR /&gt;
...| where field in("value1","value2", ...)&lt;BR /&gt;
...| eval new_field=in(field,"value1","value2", ...)&lt;/P&gt;</description>
    <pubDate>Wed, 04 Oct 2017 15:09:43 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2017-10-04T15:09:43Z</dc:date>
    <item>
      <title>Splunks equivalent to the SQL "IN" ()  function</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunks-equivalent-to-the-SQL-quot-IN-quot-function/m-p/44391#M179193</link>
      <description>&lt;P&gt;I'm trying to create a search form that can take a comma separated list. In sql I would use the 'IN' command.&lt;/P&gt;

&lt;P&gt;If the form allowed for a comma separated list like "Honda,Chevorlet,FORD,TOYOTA"&lt;BR /&gt;
I guess the search would look similar to this.&lt;/P&gt;

&lt;P&gt;search index=Cars CAR_MAKE IN ($CAR_MAKE$)|table CAR_MAKE CAR_MODEL&lt;/P&gt;

&lt;P&gt;Any Ideas?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 13:24:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunks-equivalent-to-the-SQL-quot-IN-quot-function/m-p/44391#M179193</guid>
      <dc:creator>marquiselee</dc:creator>
      <dc:date>2020-09-28T13:24:06Z</dc:date>
    </item>
    <item>
      <title>Re: Splunks equivalent to the SQL "IN" ()  function</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunks-equivalent-to-the-SQL-quot-IN-quot-function/m-p/44392#M179194</link>
      <description>&lt;P&gt;Map might work for you, but the more in the list, the longer it takes.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;|eval cars=$car_make$|eval car=split(cars,",")|map [search index=Cars car=$car$]&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;You can also try using a lookup. In &lt;CODE&gt;$APP_HOME/lookups&lt;/CODE&gt; make a "cars.csv".&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;cars.csv&lt;BR /&gt;
car&lt;BR /&gt;
Ford&lt;BR /&gt;
Toyota&lt;BR /&gt;
Honda&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Then search&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;index=Cars | join car [|inputlookup cars.csv |stats count by car|fields - count]&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Feb 2013 20:49:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunks-equivalent-to-the-SQL-quot-IN-quot-function/m-p/44392#M179194</guid>
      <dc:creator>alacercogitatus</dc:creator>
      <dc:date>2013-02-26T20:49:32Z</dc:date>
    </item>
    <item>
      <title>Re: Splunks equivalent to the SQL "IN" ()  function</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunks-equivalent-to-the-SQL-quot-IN-quot-function/m-p/44393#M179195</link>
      <description>&lt;P&gt;You could use this subquery in the main search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=Cars [| gentimes start=-1 increment=1d | eval CAR_MAKE = "foo,bar,baz" | makemv CAR_MAKE delim="," | mvexpand CAR_MAKE | return 100 CAR_MAKE]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The subsearch yields this as a filter for the main search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(CAR_MAKE="foo") OR (CAR_MAKE="bar") OR (CAR_MAKE="baz")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Just replace the fixed string with the appropriate $value$.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Feb 2013 21:24:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunks-equivalent-to-the-SQL-quot-IN-quot-function/m-p/44393#M179195</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2013-02-26T21:24:58Z</dc:date>
    </item>
    <item>
      <title>Re: Splunks equivalent to the SQL "IN" ()  function</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunks-equivalent-to-the-SQL-quot-IN-quot-function/m-p/44394#M179196</link>
      <description>&lt;P&gt;This worked perfectly!  Thank You Thank You&lt;/P&gt;</description>
      <pubDate>Tue, 26 Feb 2013 22:51:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunks-equivalent-to-the-SQL-quot-IN-quot-function/m-p/44394#M179196</guid>
      <dc:creator>marquiselee</dc:creator>
      <dc:date>2013-02-26T22:51:10Z</dc:date>
    </item>
    <item>
      <title>Re: Splunks equivalent to the SQL "IN" ()  function</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunks-equivalent-to-the-SQL-quot-IN-quot-function/m-p/44395#M179197</link>
      <description>&lt;P&gt;We can all celebrate v6.6.1:&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/SplunkCloud/6.6.1/ReleaseNotes/NewSplunkCloudFeatures"&gt;http://docs.splunk.com/Documentation/SplunkCloud/6.6.1/ReleaseNotes/NewSplunkCloudFeatures&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Because this:&lt;BR /&gt;
New SQL-like IN SPL operator    New SPL operator that acts as a shorthand for multiple disjunctions of one field.   See Comparison and Conditional functions and search in the Search Reference manual.&lt;/P&gt;

&lt;P&gt;So this:&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/SplunkCloud/6.6.1/SearchReference/ConditionalFunctions#in.28VALUE-LIST.29"&gt;http://docs.splunk.com/Documentation/SplunkCloud/6.6.1/SearchReference/ConditionalFunctions#in.28VALUE-LIST.29&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;And this:&lt;BR /&gt;
You can use this function with the eval, fieldformat, and where commands, and as part of eval expressions with other commands.&lt;BR /&gt;
There is also an IN operator that is similar to the in(VALUE-LIST) function that you can use with the search and tstats commands.&lt;BR /&gt;
The following syntax is supported:&lt;BR /&gt;
...| where in(field,"value1","value2", ...)&lt;BR /&gt;
...| where field in("value1","value2", ...)&lt;BR /&gt;
...| eval new_field=in(field,"value1","value2", ...)&lt;/P&gt;</description>
      <pubDate>Wed, 04 Oct 2017 15:09:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunks-equivalent-to-the-SQL-quot-IN-quot-function/m-p/44395#M179197</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-10-04T15:09:43Z</dc:date>
    </item>
  </channel>
</rss>

