Note that there are some explanatory texts on larger screens.

plurals
  1. POSubqueries yielding more results then expected on join of two subsets
    primarykey
    data
    text
    <p>I'm receiving more ID's then possible after performing a left outer join statement on two tables.</p> <p>Context: I've narrowed down two tables from larger data sets. Below are the queries found I've used to obtain IDs possible after selecting from the larger data set. I am trying to JOIN two data sets together based upon the personID. I am preforming a LEFT JOIN because I want to retain all data in the smallerset table while pairing it with data from narrowed data table. </p> <p>Upon running this query on a subset of a larger data set I receive the following IDs:</p> <pre><code>select s.personID from st.smallerset as s; 41486 41490 41493 41496 ... </code></pre> <p>Now, upon running the second query, I receive the following:</p> <pre><code>select r.* from st.secondlargedataset as r, st.condition as h where r.personID=h.personID group by r.personID; </code></pre> <p>I receive the following queries: </p> <pre><code>41544 41577 41595 41605 ... </code></pre> <p>So far, so good. Everything is as expected. However, when I run this next subquery as I try to join these two subsets I get unexpected results.</p> <pre><code>select s.personID from st.smallerset as s left join (select r.* from st.secondlargedataset as r, st.condition as h where r.personID=h.personID group by r.personID) as v on s.personID=v.personID; 41485 41486 41489 41490 41493 41496 41510 41512 41513 41516 </code></pre> <p>Included in this result is data that is not include in either prior query. Specifically IDs <code>41485</code>, <code>41489</code>, <code>41496</code> et cetera. I'm clueless as to why these IDs are appearing since when I break the queries into separate queries I get the IDs I need.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload