<?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: Union in Splunk like in MySQL in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/Union-in-Splunk-like-in-MySQL/m-p/61666#M854</link>
    <description>&lt;P&gt;Splunks outer join is not the same as a union. It takes all events from the main search and adds matching fields from the subsearch. BUT it discards events from the subsearch that are not matched by any event in the main search.&lt;/P&gt;</description>
    <pubDate>Thu, 03 Jul 2014 21:02:29 GMT</pubDate>
    <dc:creator>helge</dc:creator>
    <dc:date>2014-07-03T21:02:29Z</dc:date>
    <item>
      <title>Union in Splunk like in MySQL</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Union-in-Splunk-like-in-MySQL/m-p/61659#M847</link>
      <description>&lt;P&gt;Hello, i need do something like this&lt;/P&gt;

&lt;P&gt;select t_resources.t_name, t_users.t_nick&lt;BR /&gt;
  from t_resources&lt;BR /&gt;
  &lt;STRONG&gt;left&lt;/STRONG&gt; join t_users on t_users.t_id = t_resources.t_userid&lt;BR /&gt;
union&lt;BR /&gt;
select t_resources.t_name, t_users.t_nick&lt;BR /&gt;
  from t_resources&lt;BR /&gt;
  &lt;STRONG&gt;right&lt;/STRONG&gt; join t_users on t_users.t_id = t_resources.t_userid&lt;/P&gt;

&lt;P&gt;I know there is only left join in Splunk, i can get right join from left by exchanging names of tables.&lt;BR /&gt;
How can i get union operator?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 13:31:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Union-in-Splunk-like-in-MySQL/m-p/61659#M847</guid>
      <dc:creator>andrey2007</dc:creator>
      <dc:date>2020-09-28T13:31:04Z</dc:date>
    </item>
    <item>
      <title>Re: Union in Splunk like in MySQL</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Union-in-Splunk-like-in-MySQL/m-p/61660#M848</link>
      <description>&lt;P&gt;Could this page be of help to you?&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/SQLtoSplunk"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/SQLtoSplunk&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;/K&lt;/P&gt;</description>
      <pubDate>Thu, 14 Mar 2013 16:40:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Union-in-Splunk-like-in-MySQL/m-p/61660#M848</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2013-03-14T16:40:10Z</dc:date>
    </item>
    <item>
      <title>Re: Union in Splunk like in MySQL</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Union-in-Splunk-like-in-MySQL/m-p/61661#M849</link>
      <description>&lt;P&gt;The set command has the ability to union two sub searches:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| set union [search foo] [search bar]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So just figure out the base searches for the two queries you're trying to do separately, then throw them in the subsearch brackets above.&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/5.0.2/SearchReference/Set"&gt;Set Reference&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;However, I'm not sure why the SQL you presented needs a union in the first place.  I'm assuming the goal is to get all records from t_resources and t_users, matching where possible, and retaining all records from either table that do not have a match.  That can be simplified to a full outer join in mySQL, and appears to be possible with the Splunk join command:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | join type=outer field [search foo]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/5.0.2/SearchReference/Join"&gt;Join Reference&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Mar 2013 01:28:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Union-in-Splunk-like-in-MySQL/m-p/61661#M849</guid>
      <dc:creator>emiller42</dc:creator>
      <dc:date>2013-03-15T01:28:59Z</dc:date>
    </item>
    <item>
      <title>Re: Union in Splunk like in MySQL</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Union-in-Splunk-like-in-MySQL/m-p/61662#M850</link>
      <description>&lt;P&gt;There is probably an even easier Splunk solution, but it is hard to see when you express the problem in SQL. If you can express the problem in words, we may be able to  break through to a different, more "Splunk-like" point-of-view.&lt;/P&gt;

&lt;P&gt;For example, if I say: I have a table that associates users with resources. I also have a record of which users were logged-in. How can I see which resources were in use over a period of time?&lt;/P&gt;

&lt;P&gt;My answer would be: put the user-to-resource mapping in a lookup table. Then run a search like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source="myuserrecord" 
| lookup resource-lookup userId
| stats count by resourceId
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Or, you could use the &lt;CODE&gt;join&lt;/CODE&gt; command or maybe the &lt;CODE&gt;append&lt;/CODE&gt; command or even the &lt;CODE&gt;union&lt;/CODE&gt; command. But without any background on your data, it's hard to give good advice. (It would also be helpful to know how &lt;EM&gt;much&lt;/EM&gt; data you have. Do you need to run this search over thousands of events or billions of events, etc.)&lt;/P&gt;</description>
      <pubDate>Fri, 15 Mar 2013 02:00:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Union-in-Splunk-like-in-MySQL/m-p/61662#M850</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2013-03-15T02:00:20Z</dc:date>
    </item>
    <item>
      <title>Re: Union in Splunk like in MySQL</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Union-in-Splunk-like-in-MySQL/m-p/61663#M851</link>
      <description>&lt;P&gt;the final goal of my question is to know how can i realize in splunk full outer join, &lt;/P&gt;

&lt;P&gt;i made something like this&lt;BR /&gt;
(search1) join by field [search2] | append [(search2) join by field [search1]]| dedup field&lt;/P&gt;

&lt;P&gt;it works correct, but it looks terrible and not optimal.&lt;BR /&gt;
Search on 200 events takes near 7 seconds, but this search is for 3000 events&lt;/P&gt;</description>
      <pubDate>Fri, 15 Mar 2013 11:52:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Union-in-Splunk-like-in-MySQL/m-p/61663#M851</guid>
      <dc:creator>andrey2007</dc:creator>
      <dc:date>2013-03-15T11:52:45Z</dc:date>
    </item>
    <item>
      <title>Re: Union in Splunk like in MySQL</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Union-in-Splunk-like-in-MySQL/m-p/61664#M852</link>
      <description>&lt;P&gt;why can't you just say&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;(search1) OR (search2)&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 17 Mar 2013 06:18:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Union-in-Splunk-like-in-MySQL/m-p/61664#M852</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2013-03-17T06:18:31Z</dc:date>
    </item>
    <item>
      <title>Re: Union in Splunk like in MySQL</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Union-in-Splunk-like-in-MySQL/m-p/61665#M853</link>
      <description>&lt;P&gt;I need to group events by 3 filelds ip,login,city&lt;/P&gt;

&lt;P&gt;user1 192.168.1.1 London field4...fieldn &lt;BR /&gt;
user1 192.168.1.1 London field4...fieldn &lt;BR /&gt;
user1 192.168.1.1 London field4...fieldn&lt;/P&gt;

&lt;P&gt;user1 2.2.2.2 London field4...fieldn&lt;BR /&gt;
user1 2.2.2.2 London field4...fieldn&lt;BR /&gt;
 ....&lt;BR /&gt;
user10 4.4.4.4 NY field4...fieldn&lt;BR /&gt;
user10 4.4.4.4 NY field4...fieldn&lt;BR /&gt;
user10 4.4.4.4 NY field4...fieldn&lt;BR /&gt;
after this i need to calculate custom fields INSIDE EVERY GROUP, for example sum of events in group with field4&lt;CODE&gt;s value=5, minimal value of fieldn where field4=12 and etc. in one table-report&lt;BR /&gt;
What&lt;/CODE&gt;s the best way to do it?&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2013 11:34:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Union-in-Splunk-like-in-MySQL/m-p/61665#M853</guid>
      <dc:creator>andrey2007</dc:creator>
      <dc:date>2013-03-21T11:34:13Z</dc:date>
    </item>
    <item>
      <title>Re: Union in Splunk like in MySQL</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Union-in-Splunk-like-in-MySQL/m-p/61666#M854</link>
      <description>&lt;P&gt;Splunks outer join is not the same as a union. It takes all events from the main search and adds matching fields from the subsearch. BUT it discards events from the subsearch that are not matched by any event in the main search.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Jul 2014 21:02:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Union-in-Splunk-like-in-MySQL/m-p/61666#M854</guid>
      <dc:creator>helge</dc:creator>
      <dc:date>2014-07-03T21:02:29Z</dc:date>
    </item>
  </channel>
</rss>

