<?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: dbquery - create a field using a field value in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/dbquery-create-a-field-using-a-field-value/m-p/314171#M94030</link>
    <description>&lt;P&gt;In &lt;CODE&gt;SPL&lt;/CODE&gt; after it is pulled in, like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Your Base Search Here
| streamstats count AS serial
| eval KVP=mvzip(CUSTOM_FIELD_NAME,  STRINGVALUE, "=")
| mvexpand KVP
| rex field=KVP "^(?&amp;lt;KVP_key&amp;gt;[^=]+)=(?&amp;lt;KVP_value&amp;gt;[^=]+)$"
| eval {KVP_key}=KVP_value
| fields - KVP* 
| rename COMMENT AS "If you need to reconstitute original events, then add in the next line (or similar)"
| rename COMMENT AS "| stats values(_time) AS _time values(*) AS * BY serial"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 17 Jul 2017 14:33:29 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2017-07-17T14:33:29Z</dc:date>
    <item>
      <title>dbquery - create a field using a field value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/dbquery-create-a-field-using-a-field-value/m-p/314170#M94029</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I am using sql query with dbquery to get data of an item from 2 different tables.&lt;BR /&gt;
In the first table I have the Item table that has the most data on it.&lt;BR /&gt;
the second table:&lt;BR /&gt;
&lt;IMG src="https://community.splunk.com/storage/temp/206857-capture.png" alt="alt text" /&gt;&lt;/P&gt;

&lt;P&gt;I would like to join the tables and to get the CUSTOM_FIELD_NAME field as a field and the STRINGVALUE field as the value.&lt;BR /&gt;
for example, I have an item with ItemID=30, and in the second table I am having 3 record with the ItemID=30: &lt;BR /&gt;
Customer Name=ENG GEN&lt;BR /&gt;
Area=Backup&lt;BR /&gt;
Location=Haifa&lt;/P&gt;

&lt;P&gt;and I need the table after the join between the 2 tables to look like that:&lt;/P&gt;

&lt;P&gt;ItemID        Item Name        Customer Name        Area         Location&lt;BR /&gt;
    30                  aaa                      ENG GEN            Backup         Haifa&lt;BR /&gt;
    40                  bbb                           IT                    Backup         Haifa&lt;BR /&gt;
    50                  ccc                             IT                  Windows       Tel Aviv&lt;/P&gt;

&lt;P&gt;How do I join the tables with the ability to have the fields like that?&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 14:55:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/dbquery-create-a-field-using-a-field-value/m-p/314170#M94029</guid>
      <dc:creator>matansocher</dc:creator>
      <dc:date>2020-09-29T14:55:17Z</dc:date>
    </item>
    <item>
      <title>Re: dbquery - create a field using a field value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/dbquery-create-a-field-using-a-field-value/m-p/314171#M94030</link>
      <description>&lt;P&gt;In &lt;CODE&gt;SPL&lt;/CODE&gt; after it is pulled in, like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Your Base Search Here
| streamstats count AS serial
| eval KVP=mvzip(CUSTOM_FIELD_NAME,  STRINGVALUE, "=")
| mvexpand KVP
| rex field=KVP "^(?&amp;lt;KVP_key&amp;gt;[^=]+)=(?&amp;lt;KVP_value&amp;gt;[^=]+)$"
| eval {KVP_key}=KVP_value
| fields - KVP* 
| rename COMMENT AS "If you need to reconstitute original events, then add in the next line (or similar)"
| rename COMMENT AS "| stats values(_time) AS _time values(*) AS * BY serial"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 17 Jul 2017 14:33:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/dbquery-create-a-field-using-a-field-value/m-p/314171#M94030</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-07-17T14:33:29Z</dc:date>
    </item>
  </channel>
</rss>

