<?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 dbxquery inside a search in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/dbxquery-inside-a-search/m-p/556620#M158087</link>
    <description>&lt;P&gt;How do I take the results of a search pass a field into a dbxquery and then display results from both the search and the dbxquery?&lt;/P&gt;&lt;P&gt;In this example, the search returns data about specific emails where the sender domain is found in the csv file lookup.&amp;nbsp; I then want to take the Sender email address, use it in the WHERE clause&amp;nbsp; of the dbquery to return the accoutname field from the db.&amp;nbsp; Then finally, display various fields in a table including results from the search and the field returned by the dbxquery select.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=email Act IN ("Acc") Sender!="*mydomain.com"
 [ | inputlookup susDomains.csv
    | stats values(domain) AS search
    | format ]
| eval senderEmail=split(Sender,"@")
| eval senderDomain=mvindex(senderEmail,1)
| eval acctCode=if ((acc="CAU3A274"),"Admin","Manager")
| eval SQLRcpt = "'".Rcpt."'"
| map search="| dbxquery query=\"SELECT accountname
    FROM [IDM].[drip].[usr_hist_tbl] uht
    WHERE uht.mail = $SQLRcpt$ ; \" connection=\"Subscriber_History\""
| table _time,senderDomain,Sender,Rcpt,Subject,acctCode,accoutname,SQLRcpt
| sort -_time&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This search returns no data when I know there are records that should be returned.&lt;/P&gt;&lt;P&gt;Can anyone see where I may have gone wrong?&lt;/P&gt;&lt;P&gt;Thanks&lt;BR /&gt;Leigh&lt;/P&gt;</description>
    <pubDate>Tue, 22 Jun 2021 06:13:36 GMT</pubDate>
    <dc:creator>balcv</dc:creator>
    <dc:date>2021-06-22T06:13:36Z</dc:date>
    <item>
      <title>dbxquery inside a search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/dbxquery-inside-a-search/m-p/556620#M158087</link>
      <description>&lt;P&gt;How do I take the results of a search pass a field into a dbxquery and then display results from both the search and the dbxquery?&lt;/P&gt;&lt;P&gt;In this example, the search returns data about specific emails where the sender domain is found in the csv file lookup.&amp;nbsp; I then want to take the Sender email address, use it in the WHERE clause&amp;nbsp; of the dbquery to return the accoutname field from the db.&amp;nbsp; Then finally, display various fields in a table including results from the search and the field returned by the dbxquery select.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=email Act IN ("Acc") Sender!="*mydomain.com"
 [ | inputlookup susDomains.csv
    | stats values(domain) AS search
    | format ]
| eval senderEmail=split(Sender,"@")
| eval senderDomain=mvindex(senderEmail,1)
| eval acctCode=if ((acc="CAU3A274"),"Admin","Manager")
| eval SQLRcpt = "'".Rcpt."'"
| map search="| dbxquery query=\"SELECT accountname
    FROM [IDM].[drip].[usr_hist_tbl] uht
    WHERE uht.mail = $SQLRcpt$ ; \" connection=\"Subscriber_History\""
| table _time,senderDomain,Sender,Rcpt,Subject,acctCode,accoutname,SQLRcpt
| sort -_time&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This search returns no data when I know there are records that should be returned.&lt;/P&gt;&lt;P&gt;Can anyone see where I may have gone wrong?&lt;/P&gt;&lt;P&gt;Thanks&lt;BR /&gt;Leigh&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jun 2021 06:13:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/dbxquery-inside-a-search/m-p/556620#M158087</guid>
      <dc:creator>balcv</dc:creator>
      <dc:date>2021-06-22T06:13:36Z</dc:date>
    </item>
  </channel>
</rss>

