<?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: how can we add a condition of selection in sql query using db_connect and field input in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/how-can-we-add-a-condition-of-selection-in-sql-query-using-db/m-p/111804#M29311</link>
    <description>&lt;P&gt;Read all about creating forms with user inputs (I would suggest &lt;CODE&gt;dropdown&lt;/CODE&gt; for your case) here:&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/Viz/Buildandeditforms"&gt;http://docs.splunk.com/Documentation/Splunk/latest/Viz/Buildandeditforms&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 09 Jul 2015 14:46:50 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2015-07-09T14:46:50Z</dc:date>
    <item>
      <title>how can we add a condition of selection in sql query using db_connect and field input</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-can-we-add-a-condition-of-selection-in-sql-query-using-db/m-p/111803#M29310</link>
      <description>&lt;P&gt;hi every one, &lt;BR /&gt;
how can we add a condition of selection in sql query using db_connect .&lt;/P&gt;

&lt;P&gt;what I want to do is to create a input field to give the user the opprtunity to get just data correspending to one automaker (the user will enter his choice in the text field) . below  the  data that I have in my splunk server&lt;/P&gt;

&lt;P&gt;model=focus;year=2000;automaker=ford;country=usa&lt;BR /&gt;
model=cmax;year=2008;automaker=citroen;country=usa&lt;BR /&gt;
model=logan;year=2008;automaker=dacia;country=morroco&lt;BR /&gt;
model=lodgy;year=2008;automaker=dacia;country=morroco&lt;BR /&gt;
model=golf;year=2008;automaker=volswagen;country=Germany&lt;BR /&gt;
model=polo;year=2008;automaker=volswagen;country=Germany&lt;BR /&gt;
model=a4;year=2008;automaker=audi;country=Germany&lt;BR /&gt;
model=a5;year=2008;automaker=audi;country=Germany&lt;BR /&gt;
model=a3;year=2008;automaker=audi;country=Germany&lt;BR /&gt;
model=a3;year=2000;automaker=audi;country=Germany&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jul 2015 14:18:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-can-we-add-a-condition-of-selection-in-sql-query-using-db/m-p/111803#M29310</guid>
      <dc:creator>otman01</dc:creator>
      <dc:date>2015-07-09T14:18:05Z</dc:date>
    </item>
    <item>
      <title>Re: how can we add a condition of selection in sql query using db_connect and field input</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-can-we-add-a-condition-of-selection-in-sql-query-using-db/m-p/111804#M29311</link>
      <description>&lt;P&gt;Read all about creating forms with user inputs (I would suggest &lt;CODE&gt;dropdown&lt;/CODE&gt; for your case) here:&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/Viz/Buildandeditforms"&gt;http://docs.splunk.com/Documentation/Splunk/latest/Viz/Buildandeditforms&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jul 2015 14:46:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-can-we-add-a-condition-of-selection-in-sql-query-using-db/m-p/111804#M29311</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-07-09T14:46:50Z</dc:date>
    </item>
    <item>
      <title>Re: how can we add a condition of selection in sql query using db_connect and field input</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-can-we-add-a-condition-of-selection-in-sql-query-using-db/m-p/111805#M29312</link>
      <description>&lt;P&gt;it doesn't work&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jul 2015 08:10:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-can-we-add-a-condition-of-selection-in-sql-query-using-db/m-p/111805#M29312</guid>
      <dc:creator>otman01</dc:creator>
      <dc:date>2015-07-10T08:10:51Z</dc:date>
    </item>
    <item>
      <title>Re: how can we add a condition of selection in sql query using db_connect and field input</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-can-we-add-a-condition-of-selection-in-sql-query-using-db/m-p/111806#M29313</link>
      <description>&lt;P&gt;It works if the data is stored in Splunk server. but if I try to extract data from MySQL database it doesn't work this is the command that I used :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| dbquery "db_ventes" "SELECT model, year, automaker, pays FROM cars c , automaker a where c.automaker=a.automaker " automaker=$automaker$ | fields model, year, automaker, country

         &amp;lt;label&amp;gt;sourcetype&amp;lt;/label&amp;gt;
            &amp;lt;default&amp;gt;splunkd&amp;lt;/default&amp;gt;
            &amp;lt;choice value="splunk_web_access"&amp;gt;audi&amp;lt;/choice&amp;gt;
            &amp;lt;choice value="splunkd_ui_access"&amp;gt;dacia&amp;lt;/choice&amp;gt;
         &amp;lt;/input&amp;gt;
 &amp;lt;/fieldset&amp;gt;

 &amp;lt;option name="showPager"&amp;gt;true&amp;lt;/option&amp;gt;
 &amp;lt;option name="count"&amp;gt;20&amp;lt;/option&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;thank you &lt;/P&gt;</description>
      <pubDate>Fri, 10 Jul 2015 08:23:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-can-we-add-a-condition-of-selection-in-sql-query-using-db/m-p/111806#M29313</guid>
      <dc:creator>otman01</dc:creator>
      <dc:date>2015-07-10T08:23:57Z</dc:date>
    </item>
    <item>
      <title>Re: how can we add a condition of selection in sql query using db_connect and field input</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-can-we-add-a-condition-of-selection-in-sql-query-using-db/m-p/111807#M29314</link>
      <description>&lt;P&gt;i solved the issue by adding the &lt;STRONG&gt;search&lt;/STRONG&gt; command instead of &lt;STRONG&gt;where&lt;/STRONG&gt;  command&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jul 2015 13:13:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-can-we-add-a-condition-of-selection-in-sql-query-using-db/m-p/111807#M29314</guid>
      <dc:creator>otman01</dc:creator>
      <dc:date>2015-07-10T13:13:13Z</dc:date>
    </item>
    <item>
      <title>Re: how can we add a condition of selection in sql query using db_connect and field input</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-can-we-add-a-condition-of-selection-in-sql-query-using-db/m-p/111808#M29315</link>
      <description>&lt;P&gt;Your command is slightly wrong; try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| dbquery "db_ventes" "SELECT model, year, automaker, pays FROM cars c , automaker a where c.automaker=a.automaker " | search automaker="$automaker$" | fields model, year, automaker, country
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Or even this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| dbquery "db_ventes" "SELECT model, year, automaker, pays FROM cars c , automaker a where c.automaker=a.automaker AND c.automaker=$automaker$" | fields model, year, automaker, country
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 10 Jul 2015 13:18:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-can-we-add-a-condition-of-selection-in-sql-query-using-db/m-p/111808#M29315</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-07-10T13:18:37Z</dc:date>
    </item>
    <item>
      <title>Re: how can we add a condition of selection in sql query using db_connect and field input</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-can-we-add-a-condition-of-selection-in-sql-query-using-db/m-p/111809#M29316</link>
      <description>&lt;P&gt;this is the hol command &lt;/P&gt;

&lt;P&gt;|dbquery "db_ventes" "SELECT model, year, automaker, pays  FROM cars c, automaker a where c.automaker=a.automaker "   | search automaker="$automaker$"    | fields  model, year, automaker, pays&lt;/P&gt;

&lt;P&gt;It works perfectley&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jul 2015 13:28:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-can-we-add-a-condition-of-selection-in-sql-query-using-db/m-p/111809#M29316</guid>
      <dc:creator>otman01</dc:creator>
      <dc:date>2015-07-10T13:28:47Z</dc:date>
    </item>
    <item>
      <title>Re: how can we add a condition of selection in sql query using db_connect and field input</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-can-we-add-a-condition-of-selection-in-sql-query-using-db/m-p/111810#M29317</link>
      <description>&lt;P&gt;hhhhhhhhh its the same sorry &lt;/P&gt;</description>
      <pubDate>Fri, 10 Jul 2015 13:29:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-can-we-add-a-condition-of-selection-in-sql-query-using-db/m-p/111810#M29317</guid>
      <dc:creator>otman01</dc:creator>
      <dc:date>2015-07-10T13:29:44Z</dc:date>
    </item>
    <item>
      <title>Re: how can we add a condition of selection in sql query using db_connect and field input</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-can-we-add-a-condition-of-selection-in-sql-query-using-db/m-p/111811#M29318</link>
      <description>&lt;P&gt;this is the right answer :&lt;BR /&gt;
| dbquery "db_ventes" "SELECT model, year, automaker, pays FROM cars c, automaker a where c.automaker=a.automaker " | search automaker="$automaker$" | fields model, year, automaker, pays&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jul 2015 13:32:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-can-we-add-a-condition-of-selection-in-sql-query-using-db/m-p/111811#M29318</guid>
      <dc:creator>otman01</dc:creator>
      <dc:date>2015-07-10T13:32:00Z</dc:date>
    </item>
    <item>
      <title>Re: how can we add a condition of selection in sql query using db_connect and field input</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-can-we-add-a-condition-of-selection-in-sql-query-using-db/m-p/111812#M29319</link>
      <description>&lt;P&gt;@woodcock's 2nd search below the text that reads "or even this" is by far the best/correct way to do it. I have searches running that way in my environment as well and that method does work. &lt;/P&gt;

&lt;P&gt;I'm specifically referring to this part of passing the token into the query:&lt;BR /&gt;
AND c.automaker=$automaker$"&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jul 2015 20:08:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-can-we-add-a-condition-of-selection-in-sql-query-using-db/m-p/111812#M29319</guid>
      <dc:creator>hogan24</dc:creator>
      <dc:date>2015-07-23T20:08:37Z</dc:date>
    </item>
  </channel>
</rss>

