title: SQLite query to get corresponding data
body: <p>I have some database tables that holds rooms and another table that holds exits of that rooms:</p>
  
  <p>rooms Table:</p>
  
  <pre><code>+---------------+----------------+----------------+
  | uid (integer) | name (varchar) | area (varchar) |
  +---------------+----------------+----------------+
  </code></pre>
  
  <p>exits Table:</p>
  
  <pre><code>+------------+---------+-------+
  | direction  | fromuid | touid |
  +------------+---------+-------+
  </code></pre>
  
  <p>there is 6 possible direction for each room: north, south, west, east, up, down</p>
  
  <p>I want to get all <code>uid</code>s from current <code>uid</code> to all directions with 3 depth.</p>
  
  <p>What I mean is: for example for north room's north room and that one's north room and that one's north room also.</p>
  
  <pre><code>         |n3|                    |u3|
           |n2|                    |u2|
           |n1|                    |u1|
  |w3|w2|w1|  |e1|e2|e3|    and
           |s1|                    |d1|
           |s2|                    |d2|
           |s3|                    |d3|
  </code></pre>
  
  <p>Like this I want to get all rooms <code>uid</code>s with keys like n1, n2, n3 etc.</p>
  
  <p>Is that possible with one query?</p>
  
  <p>Also note that some directions are not have 3 rooms. For example east direction can have only 1 room or other directions cant have any room at all</p>