<?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: Why does the Join query only work if I write a query in the most inefficient way? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Why-does-the-Join-query-only-work-if-I-write-a-query-in-the-most/m-p/363493#M107329</link>
    <description>&lt;P&gt;Any chance this code does what you're looking for? &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| ldapsearch domain=ED-people search="objectClass=eduPerson" attrs="weillCornellEduCWID,weillCornellEduPrimaryTitle"
| table weillCornellEduCWID, weillCornellEduPrimaryTitle
| rename weillCornellEduCWID AS CWID
| append [
| dbquery "AcctAdmin" "select CWID, authorization_pk from people_db.authorization a  
 left join people_db.service s on s.service_pk = a.service_fk  
 left join people_db.person p on p.PERSON_PK = a.PERSON_FK 
 where CWID ='paa2013'"  ]
| stats values(*) AS * BY CWID
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 09 Feb 2018 17:51:00 GMT</pubDate>
    <dc:creator>elliotproebstel</dc:creator>
    <dc:date>2018-02-09T17:51:00Z</dc:date>
    <item>
      <title>Why does the Join query only work if I write a query in the most inefficient way?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-the-Join-query-only-work-if-I-write-a-query-in-the-most/m-p/363492#M107328</link>
      <description>&lt;P&gt;I am trying to join the results of two searches so it looks like this:&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;CWID, authorization_pk,weillCornellEduPrimaryTitle&lt;/STRONG&gt;&lt;BR /&gt;
   paa2013, 1234, IT Support Manager&lt;BR /&gt;
   paa2013, 5678, IT Support Manager&lt;BR /&gt;
   paa2013, 9123, IT Support Manager&lt;/P&gt;

&lt;P&gt;**&lt;/P&gt;

&lt;P&gt;The "AcctAdmin" search returns only 3 results...&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;CWID, authorization_pk&lt;/STRONG&gt;&lt;BR /&gt;
   paa2013, 1234&lt;BR /&gt;
   paa2013, 5678&lt;BR /&gt;
   paa2013, 9123&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;The "LDAP" search returns 150,000 results...&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;CWID, weillCornellEduPrimaryTitle&lt;/STRONG&gt;&lt;BR /&gt;
  paa2013, IT Support Manager&lt;BR /&gt;
  brb2009, Professor&lt;BR /&gt;
  ala9001, Help Desk Technician&lt;BR /&gt;
  [150,000 more results!]&lt;/P&gt;

&lt;P&gt;**&lt;/P&gt;

&lt;P&gt;Search #1, in which I start with the smaller result and join against the larger result. I presume this would be more efficient, but it doesn't work:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| dbquery "AcctAdmin" "select CWID, authorization_pk from database.authorization a  
left join people_db.service s on s.service_pk = a.service_fk  
left join people_db.person p on p.PERSON_PK = a.PERSON_FK 
where CWID ='paa2013'"  
| rename CWID as weillCornellEduCWID
| join weillCornellEduCWID [
| ldapsearch domain=ED-people search="objectClass=eduPerson" attrs="weillCornellEduCWID,weillCornellEduPrimaryTitle"
| table weillCornellEduCWID, weillCornellEduPrimaryTitle
]
| table *
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Search #2, in which I start with the larger result and join against the smaller result, does:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| ldapsearch domain=ED-people search="objectClass=eduPerson" attrs="weillCornellEduCWID,weillCornellEduPrimaryTitle"
| table weillCornellEduCWID, weillCornellEduPrimaryTitle
| rename weillCornellEduCWID AS CWID
| join CWID [
| dbquery "AcctAdmin" "select CWID, authorization_pk from people_db.database a  
left join people_db.service s on s.service_pk = a.service_fk  
left join people_db.person p on p.PERSON_PK = a.PERSON_FK 
where CWID ='paa2013'"  ]
| table *
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;A lot of answers here suggest JOIN is inefficient but I don't see another way to do this. Oh, and "max=0" is no help.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Feb 2018 15:29:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-the-Join-query-only-work-if-I-write-a-query-in-the-most/m-p/363492#M107328</guid>
      <dc:creator>paulalbert</dc:creator>
      <dc:date>2018-02-09T15:29:23Z</dc:date>
    </item>
    <item>
      <title>Re: Why does the Join query only work if I write a query in the most inefficient way?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-the-Join-query-only-work-if-I-write-a-query-in-the-most/m-p/363493#M107329</link>
      <description>&lt;P&gt;Any chance this code does what you're looking for? &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| ldapsearch domain=ED-people search="objectClass=eduPerson" attrs="weillCornellEduCWID,weillCornellEduPrimaryTitle"
| table weillCornellEduCWID, weillCornellEduPrimaryTitle
| rename weillCornellEduCWID AS CWID
| append [
| dbquery "AcctAdmin" "select CWID, authorization_pk from people_db.authorization a  
 left join people_db.service s on s.service_pk = a.service_fk  
 left join people_db.person p on p.PERSON_PK = a.PERSON_FK 
 where CWID ='paa2013'"  ]
| stats values(*) AS * BY CWID
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 09 Feb 2018 17:51:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-the-Join-query-only-work-if-I-write-a-query-in-the-most/m-p/363493#M107329</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2018-02-09T17:51:00Z</dc:date>
    </item>
    <item>
      <title>Re: Why does the Join query only work if I write a query in the most inefficient way?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-the-Join-query-only-work-if-I-write-a-query-in-the-most/m-p/363494#M107330</link>
      <description>&lt;P&gt;What does each search give you and what are the expected results?&lt;/P&gt;</description>
      <pubDate>Fri, 09 Feb 2018 19:40:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-the-Join-query-only-work-if-I-write-a-query-in-the-most/m-p/363494#M107330</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2018-02-09T19:40:07Z</dc:date>
    </item>
    <item>
      <title>Re: Why does the Join query only work if I write a query in the most inefficient way?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-the-Join-query-only-work-if-I-write-a-query-in-the-most/m-p/363495#M107331</link>
      <description>&lt;P&gt;Thanks for having a look, Rich. See above.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Feb 2018 21:39:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-the-Join-query-only-work-if-I-write-a-query-in-the-most/m-p/363495#M107331</guid>
      <dc:creator>paulalbert</dc:creator>
      <dc:date>2018-02-09T21:39:15Z</dc:date>
    </item>
    <item>
      <title>Re: Why does the Join query only work if I write a query in the most inefficient way?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-the-Join-query-only-work-if-I-write-a-query-in-the-most/m-p/363496#M107332</link>
      <description>&lt;P&gt;Thanks for taking a whack but not really. This returns 150k results! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Feb 2018 21:40:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-the-Join-query-only-work-if-I-write-a-query-in-the-most/m-p/363496#M107332</guid>
      <dc:creator>paulalbert</dc:creator>
      <dc:date>2018-02-09T21:40:28Z</dc:date>
    </item>
    <item>
      <title>Re: Why does the Join query only work if I write a query in the most inefficient way?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-the-Join-query-only-work-if-I-write-a-query-in-the-most/m-p/363497#M107333</link>
      <description>&lt;P&gt;Based on the updated info, how about this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| ldapsearch domain=ED-people search="objectClass=eduPerson" attrs="weillCornellEduCWID,weillCornellEduPrimaryTitle"
| table weillCornellEduCWID, weillCornellEduPrimaryTitle
| rename weillCornellEduCWID AS CWID
| append [
 | dbquery "AcctAdmin" "select CWID, authorization_pk from people_db.authorization a  
  left join people_db.service s on s.service_pk = a.service_fk  
  left join people_db.person p on p.PERSON_PK = a.PERSON_FK 
  where CWID ='paa2013'"  ]
| stats list(CWID) AS CWID list(weillCornellEduPrimaryTitle) AS weillCornellEduPrimaryTitle BY authorization_pk
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That should bring you down to three rows again &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Feb 2018 21:50:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-the-Join-query-only-work-if-I-write-a-query-in-the-most/m-p/363497#M107333</guid>
      <dc:creator>elliotproebstel</dc:creator>
      <dc:date>2018-02-09T21:50:03Z</dc:date>
    </item>
    <item>
      <title>Re: Why does the Join query only work if I write a query in the most inefficient way?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-the-Join-query-only-work-if-I-write-a-query-in-the-most/m-p/363498#M107334</link>
      <description>&lt;P&gt;I see what you're trying to do but unfortunately, it gives me zero results. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Feb 2018 22:57:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-the-Join-query-only-work-if-I-write-a-query-in-the-most/m-p/363498#M107334</guid>
      <dc:creator>paulalbert</dc:creator>
      <dc:date>2018-02-09T22:57:06Z</dc:date>
    </item>
    <item>
      <title>Re: Why does the Join query only work if I write a query in the most inefficient way?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-the-Join-query-only-work-if-I-write-a-query-in-the-most/m-p/363499#M107335</link>
      <description>&lt;P&gt;Another exploratory thought:&lt;/P&gt;

&lt;P&gt;Is there any reason you can't create a lookup from the LDAP search?  That seems like the most efficient solution to this.&lt;/P&gt;</description>
      <pubDate>Sun, 11 Feb 2018 15:14:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-the-Join-query-only-work-if-I-write-a-query-in-the-most/m-p/363499#M107335</guid>
      <dc:creator>Richfez</dc:creator>
      <dc:date>2018-02-11T15:14:51Z</dc:date>
    </item>
    <item>
      <title>Re: Why does the Join query only work if I write a query in the most inefficient way?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-the-Join-query-only-work-if-I-write-a-query-in-the-most/m-p/363500#M107336</link>
      <description>&lt;P&gt;I would stick with what elliot is trying to do but seeing as though you have already hard coded a where clause in your DB query to limit your results, you should do the same in your LDAP query too so that it looks something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| ldapsearch domain=ED-people search="(&amp;amp;(objectClass=eduPerson)(weillCornellEduCWID=paa2013))" attrs="weillCornellEduCWID,weillCornellEduPrimaryTitle"
 | table weillCornellEduCWID, weillCornellEduPrimaryTitle
 | rename weillCornellEduCWID AS CWID
 | append [
 | dbquery "AcctAdmin" "select CWID, authorization_pk from people_db.database a  
 left join people_db.service s on s.service_pk = a.service_fk  
 left join people_db.person p on p.PERSON_PK = a.PERSON_FK 
 where CWID ='paa2013'"  ]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 11 Feb 2018 15:22:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-the-Join-query-only-work-if-I-write-a-query-in-the-most/m-p/363500#M107336</guid>
      <dc:creator>sashraf</dc:creator>
      <dc:date>2018-02-11T15:22:43Z</dc:date>
    </item>
    <item>
      <title>Re: Why does the Join query only work if I write a query in the most inefficient way?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-does-the-Join-query-only-work-if-I-write-a-query-in-the-most/m-p/363501#M107337</link>
      <description>&lt;P&gt;This works but I do need to also display weillCornellEduPrimaryTitle? That's the point of having these two searches.&lt;/P&gt;

&lt;P&gt;&lt;IMG src="https://www.dropbox.com/s/0op2p2998k04wkw/splunk23423.png?dl=1" alt="My query" /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Feb 2018 14:32:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-does-the-Join-query-only-work-if-I-write-a-query-in-the-most/m-p/363501#M107337</guid>
      <dc:creator>paulalbert</dc:creator>
      <dc:date>2018-02-13T14:32:32Z</dc:date>
    </item>
  </channel>
</rss>

