Note that there are some explanatory texts on larger screens.

plurals
  1. POSelecting unique rows in a set of two possibilities
    primarykey
    data
    text
    <p>The problem itself is simple, but I can't figure out a solution that does it in one query, and here's my "abstraction" of the problem to allow for a simpler explanation:</p> <p><strong>I will let my original explenation stand, but here's a set of sample data and the result i expect:</strong></p> <p>Ok, so here's some sample data, i separated pairs by a blank line</p> <pre><code>------------- | Key | Col | (Together they from a Unique Pair) -------------- | 1 Foo | | 1 Bar | | | | 2 Foo | | | | 3 Bar | | | | 4 Foo | | 4 Bar | -------------- </code></pre> <p>And the result I would expect, <strong>after running the query once</strong>, it need to be able to select this result set in one query:</p> <pre><code>1 - Foo 2 - Foo 3 - Bar 4 - Foo </code></pre> <p><em>Original explenation:</em></p> <p>I have a table, call it <code>TABLE</code> where I have a two columns say <code>ID</code> and <code>NAME</code> which together form the primary key of the table. Now I want to select something where <code>ID=1</code> and then first checks if it can find a row where <code>NAME</code> has the value "John", if "John" does not exist it should look for a row where <code>NAME</code> is "Bruce" - but only return "John" if both "Bruce" and "John" exists or only "John" exists of course.</p> <p>Also note that it should be able to return several rows per query that match the above criteria but with different ID/Name-combinations of course, and that the above explanation is just a simplification of the real problem.</p> <p>I could be completely blinded by my own code and line of thought but I just can't figure this out. </p>
    singulars
    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.
 

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