<?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: Whats the splunk equivalent of SQL IN clause in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Whats-the-splunk-equivalent-of-SQL-IN-clause/m-p/164335#M46677</link>
    <description>&lt;P&gt;Got this working via the inline search you mentioned in your first suggestion thanks:&lt;/P&gt;

&lt;P&gt;my_car_search | lookup cardata.csv car_make OUTPUT country | where country="Japan"&lt;/P&gt;

&lt;P&gt;Trying unsuccessfully to do it via an automatic lookup table but I believe that ultimately that would be the better solution thanks.&lt;/P&gt;</description>
    <pubDate>Mon, 28 Sep 2020 17:53:18 GMT</pubDate>
    <dc:creator>jmc82</dc:creator>
    <dc:date>2020-09-28T17:53:18Z</dc:date>
    <item>
      <title>Whats the splunk equivalent of SQL IN clause</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Whats-the-splunk-equivalent-of-SQL-IN-clause/m-p/164326#M46668</link>
      <description>&lt;P&gt;What is the Splunk equivalent of an SQL IN clause. I want to run a query where some field has a value which is present in a list of values.&lt;/P&gt;

&lt;P&gt;For example, suppose I have a list of car types, such as:&lt;/P&gt;

&lt;P&gt;BMW&lt;BR /&gt;
Volkswagon&lt;BR /&gt;
Ford&lt;/P&gt;

&lt;P&gt;And I want to query something like:&lt;/P&gt;

&lt;P&gt;CAR_MAKE IN {BMW, Volkswagon, Ford}&lt;/P&gt;

&lt;P&gt;Obviously I can query separately using &lt;/P&gt;

&lt;P&gt;CAR_MAKE = "BMW" or CAR_MAKE = "Volkswagon"... etc&lt;/P&gt;

&lt;P&gt;However my actual use case is slightly more complicated (I have an inputlookup) but the principle is the same. How can this be done?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 17:53:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Whats-the-splunk-equivalent-of-SQL-IN-clause/m-p/164326#M46668</guid>
      <dc:creator>jmc82</dc:creator>
      <dc:date>2020-09-28T17:53:02Z</dc:date>
    </item>
    <item>
      <title>Re: Whats the splunk equivalent of SQL IN clause</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Whats-the-splunk-equivalent-of-SQL-IN-clause/m-p/164327#M46669</link>
      <description>&lt;P&gt;&lt;CODE&gt;OR&lt;/CODE&gt; is how it is done in Splunk. Maybe you should provide more details about your actual use case, search string and lookup file and I'm sure someone can guide you .....&lt;/P&gt;</description>
      <pubDate>Wed, 15 Oct 2014 09:43:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Whats-the-splunk-equivalent-of-SQL-IN-clause/m-p/164327#M46669</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2014-10-15T09:43:46Z</dc:date>
    </item>
    <item>
      <title>Re: Whats the splunk equivalent of SQL IN clause</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Whats-the-splunk-equivalent-of-SQL-IN-clause/m-p/164328#M46670</link>
      <description>&lt;P&gt;OR is not feasible for me. The list is potentially a few hundred entries long and its contents can change. Surely there is a simple way of checking for membership like this without explicitly checking every member of the list using on OR clause?&lt;/P&gt;</description>
      <pubDate>Wed, 15 Oct 2014 10:39:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Whats-the-splunk-equivalent-of-SQL-IN-clause/m-p/164328#M46670</guid>
      <dc:creator>jmc82</dc:creator>
      <dc:date>2014-10-15T10:39:27Z</dc:date>
    </item>
    <item>
      <title>Re: Whats the splunk equivalent of SQL IN clause</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Whats-the-splunk-equivalent-of-SQL-IN-clause/m-p/164329#M46671</link>
      <description>&lt;P&gt;okay, without still not knowing your events nor use cases I'll give it a shot ....&lt;/P&gt;

&lt;P&gt;Assumption: you have a lookup file containing members to membership mapping. Now, you want to find a &lt;CODE&gt;user&lt;/CODE&gt; that is not mapped to any membership in your lookup file, run something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search to get user events | search NOT [ | inputlookup membership ] | ....
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Maybe this will give you some hint....&lt;/P&gt;</description>
      <pubDate>Wed, 15 Oct 2014 10:45:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Whats-the-splunk-equivalent-of-SQL-IN-clause/m-p/164329#M46671</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2014-10-15T10:45:50Z</dc:date>
    </item>
    <item>
      <title>Re: Whats the splunk equivalent of SQL IN clause</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Whats-the-splunk-equivalent-of-SQL-IN-clause/m-p/164330#M46672</link>
      <description>&lt;P&gt;Ok, sorry, I think I need to clarify my use case a bit:&lt;/P&gt;

&lt;P&gt;Suppose we have a log file containing the details of various cars. Something like:&lt;/P&gt;

&lt;P&gt;car_make = "Toyota"....&lt;BR /&gt;
car_make = "Honda"... &lt;BR /&gt;
car_make = "BMW"...   &lt;/P&gt;

&lt;P&gt;I have an inputlookup which maps the car make to its country of origin:&lt;/P&gt;

&lt;P&gt;Japan       Toyota&lt;BR /&gt;
Japan       Honda&lt;BR /&gt;
Germany BMW&lt;/P&gt;

&lt;P&gt;The user has a drop down list where they can select a country. So suppose they select 'Japan'. I then want to filter my events for all Japanese cars. So I take the value of the drop down (Japan in this example) and I search my lookup for all the cars from Japan and I get back 'Toyota' and 'Honda'. &lt;/P&gt;

&lt;P&gt;I then need my search string to have something like:&lt;/P&gt;

&lt;P&gt;car_make in {'Toyota', 'Japan'}&lt;/P&gt;

&lt;P&gt;or &lt;/P&gt;

&lt;P&gt;car_make = "Toyota" or car_make = "Honda"...etc&lt;/P&gt;

&lt;P&gt;Just to be clear, I DONT have the country of origin in my event data, so I can't simply search my events for country_of_origin='Japan' or anything like that. &lt;/P&gt;

&lt;P&gt;Thanks for your help.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 17:53:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Whats-the-splunk-equivalent-of-SQL-IN-clause/m-p/164330#M46672</guid>
      <dc:creator>jmc82</dc:creator>
      <dc:date>2020-09-28T17:53:04Z</dc:date>
    </item>
    <item>
      <title>Re: Whats the splunk equivalent of SQL IN clause</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Whats-the-splunk-equivalent-of-SQL-IN-clause/m-p/164331#M46673</link>
      <description>&lt;P&gt;Ok, the easiest thing is to read the docs on &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.1.4/Knowledge/Usefieldlookupstoaddinformationtoyourevents"&gt;http://docs.splunk.com/Documentation/Splunk/6.1.4/Knowledge/Usefieldlookupstoaddinformationtoyourevents&lt;/A&gt; and add this &lt;CODE&gt;country_of_origin&lt;/CODE&gt; field from the lookup file. After that you can search for it. &lt;/P&gt;</description>
      <pubDate>Wed, 15 Oct 2014 11:04:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Whats-the-splunk-equivalent-of-SQL-IN-clause/m-p/164331#M46673</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2014-10-15T11:04:05Z</dc:date>
    </item>
    <item>
      <title>Re: Whats the splunk equivalent of SQL IN clause</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Whats-the-splunk-equivalent-of-SQL-IN-clause/m-p/164332#M46674</link>
      <description>&lt;P&gt;I agree with MuS, you can add the country_of_origin to your events at search time using an automatic lookup. It was a bit daunting at first to get a handle on how to set them up, but you'll get the hang of it and it'll be a great tool in your Splunk toolbelt.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 17:53:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Whats-the-splunk-equivalent-of-SQL-IN-clause/m-p/164332#M46674</guid>
      <dc:creator>jeremiahc4</dc:creator>
      <dc:date>2020-09-28T17:53:09Z</dc:date>
    </item>
    <item>
      <title>Re: Whats the splunk equivalent of SQL IN clause</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Whats-the-splunk-equivalent-of-SQL-IN-clause/m-p/164333#M46675</link>
      <description>&lt;P&gt;The first thing is that splunk's query language is not SQL so looking for similar commands will not always be possible. But there is nearly always a way of doing things. &lt;/P&gt;

&lt;P&gt;Looking at your data, I would restructure the query as follows.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;my_car_search | lookup cardata.csv car_make OUTPUT country | where country="Japan"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If the lookup was made automatic, it would be a simple as&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;my_car_search country="Japan"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 Oct 2014 13:40:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Whats-the-splunk-equivalent-of-SQL-IN-clause/m-p/164333#M46675</guid>
      <dc:creator>bmunson_splunk</dc:creator>
      <dc:date>2014-10-15T13:40:36Z</dc:date>
    </item>
    <item>
      <title>Re: Whats the splunk equivalent of SQL IN clause</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Whats-the-splunk-equivalent-of-SQL-IN-clause/m-p/164334#M46676</link>
      <description>&lt;P&gt;Ok, so an autolookup table sounds like the way to go. Can someone clarify how to configure this for me? My lookup has two columns:&lt;/P&gt;

&lt;P&gt;CAR_MAKE, COUNTRY_OF_ORIGIN&lt;/P&gt;

&lt;P&gt;and my original data has a CAR_MAKE field. Based on the docs I believe my autolookup table should specify the following:&lt;/P&gt;

&lt;P&gt;Lookup input fields:&lt;BR /&gt;
CAR_MAKE = CAR_MAKE&lt;/P&gt;

&lt;P&gt;and &lt;/P&gt;

&lt;P&gt;Lookup output fields:&lt;BR /&gt;
COUNTRY_OF_ORIGIN = COUNTRY_OF_ORIGIN&lt;/P&gt;

&lt;P&gt;And this should result in the COUNTRY_OF_ORIGIN field becoming part of my events, is that correct? &lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 17:53:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Whats-the-splunk-equivalent-of-SQL-IN-clause/m-p/164334#M46676</guid>
      <dc:creator>jmc82</dc:creator>
      <dc:date>2020-09-28T17:53:14Z</dc:date>
    </item>
    <item>
      <title>Re: Whats the splunk equivalent of SQL IN clause</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Whats-the-splunk-equivalent-of-SQL-IN-clause/m-p/164335#M46677</link>
      <description>&lt;P&gt;Got this working via the inline search you mentioned in your first suggestion thanks:&lt;/P&gt;

&lt;P&gt;my_car_search | lookup cardata.csv car_make OUTPUT country | where country="Japan"&lt;/P&gt;

&lt;P&gt;Trying unsuccessfully to do it via an automatic lookup table but I believe that ultimately that would be the better solution thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 17:53:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Whats-the-splunk-equivalent-of-SQL-IN-clause/m-p/164335#M46677</guid>
      <dc:creator>jmc82</dc:creator>
      <dc:date>2020-09-28T17:53:18Z</dc:date>
    </item>
    <item>
      <title>Re: Whats the splunk equivalent of SQL IN clause</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Whats-the-splunk-equivalent-of-SQL-IN-clause/m-p/164336#M46678</link>
      <description>&lt;P&gt;Correct though technically if you are not renaming them you don't need the second part.&lt;/P&gt;

&lt;P&gt;This walks you through setting up lookups&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.1/Knowledge/Usefieldlookupstoaddinformationtoyourevents"&gt;http://docs.splunk.com/Documentation/Splunk/6.1/Knowledge/Usefieldlookupstoaddinformationtoyourevents&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Oct 2014 14:41:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Whats-the-splunk-equivalent-of-SQL-IN-clause/m-p/164336#M46678</guid>
      <dc:creator>bmunson_splunk</dc:creator>
      <dc:date>2014-10-15T14:41:57Z</dc:date>
    </item>
    <item>
      <title>Re: Whats the splunk equivalent of SQL IN clause</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Whats-the-splunk-equivalent-of-SQL-IN-clause/m-p/164337#M46679</link>
      <description>&lt;P&gt;If the values are limited then a simple query with OR clause will do its job in this case. i.e.&lt;/P&gt;

&lt;P&gt;Car_Make="Honda" OR Car_Make="Toyoto" etc.&lt;/P&gt;

&lt;P&gt;Please note that use of "OR" is case sensitive&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 10:22:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Whats-the-splunk-equivalent-of-SQL-IN-clause/m-p/164337#M46679</guid>
      <dc:creator>vkalra2924</dc:creator>
      <dc:date>2020-09-29T10:22:29Z</dc:date>
    </item>
    <item>
      <title>Re: Whats the splunk equivalent of SQL IN clause</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Whats-the-splunk-equivalent-of-SQL-IN-clause/m-p/164338#M46680</link>
      <description>&lt;P&gt;As of Splunk 6.6, you can test a list of values. However, for an extensive list, the lookup solution given is better.&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/SplunkCloud/6.6.0/SearchReference/Search#Multiple_field-value_comparisons_with_the_IN_operator"&gt;Search command supports IN operator&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;sourcetype=xyz status IN (100, 102, 103)&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/SplunkCloud/6.6.0/SearchReference/ConditionalFunctions#Description_6"&gt;Eval and where commands support in function&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;| where in(status,"222","333","444","555")&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jun 2017 20:29:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Whats-the-splunk-equivalent-of-SQL-IN-clause/m-p/164338#M46680</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2017-06-19T20:29:47Z</dc:date>
    </item>
    <item>
      <title>Re: Whats the splunk equivalent of SQL IN clause</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Whats-the-splunk-equivalent-of-SQL-IN-clause/m-p/164339#M46681</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:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Whats-the-splunk-equivalent-of-SQL-IN-clause/m-p/164339#M46681</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-10-04T15:09:57Z</dc:date>
    </item>
    <item>
      <title>Re: Whats the splunk equivalent of SQL IN clause</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Whats-the-splunk-equivalent-of-SQL-IN-clause/m-p/605540#M210573</link>
      <description>&lt;P&gt;Splunk now has an "IN" operator. So you can simply add the following to your search:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;CAR_MAKE IN (BMW, Volkswagon, Ford)&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;If your search values have spaces, it will need to be wrapped in quotations. E.g:&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;CAR_MAKE IN (BMW, Volkswagon, "Mercedes Benz", Ford)&lt;BR /&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;I know its late, but hopefully it can help people looking for it now.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Also, you may want to correct the spelling of Volkswagen &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jul 2022 07:05:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Whats-the-splunk-equivalent-of-SQL-IN-clause/m-p/605540#M210573</guid>
      <dc:creator>JohnMurphyAus</dc:creator>
      <dc:date>2022-07-14T07:05:59Z</dc:date>
    </item>
  </channel>
</rss>

