title: Filter sub arrays in AlaSQL
body: <p>I have a Javascript object being passed into AlaSQL like:</p>
  <pre><code>const details = {
    &quot;returnCode&quot;: 0,
    &quot;someProperty&quot;: {
      &quot;results&quot;: [
        {
          &quot;resultId&quot;: 1234,
          &quot;resultProperty1&quot;: &quot;asdf&quot;,
          &quot;notWantedProperty&quot;: &quot;notThis&quot;,
          &quot;anotherNotWantedProperty&quot;: &quot;orAnyOther&quot;
        },
        {
          &quot;resultId&quot;: 5678,
          &quot;resultProperty1&quot;: &quot;qwert&quot;,
          &quot;notWantedProperty&quot;: &quot;notThisEither&quot;
        }
      ]
    }
  }
  results = alasql(query, [details]);
  </code></pre>
  <p>I'm trying to use alasql to filter out like any of these with a <code>WHERE</code> query <code>&quot;resultProperty1 == &quot;asdf&quot;</code> and get a result like:</p>
  <pre><code>{
    &quot;returnCode&quot;: 0,
    &quot;results&quot;: [
      {
        &quot;resultId&quot;: 1234,
        &quot;resultProperty1&quot;: &quot;asdf&quot;
      },
    ]
  }
  -- or --
  {
    &quot;returnCode&quot;: 0,
    &quot;results&quot;: {
      &quot;resultId&quot;: 1234,
      &quot;resultProperty1&quot;: &quot;asdf&quot;
    }
  }
  -- or --
  {
    &quot;returnCode&quot;: 0,
    &quot;someProperty&quot;: {
      &quot;results&quot;: {
        &quot;resultId&quot;: 1234,
        &quot;resultProperty1&quot;: &quot;asdf&quot;
      }
    }
  }
  -- or --
  {
    &quot;returnCode&quot;: 0,
    &quot;someProperty&quot;: {
      &quot;results&quot;: [
        {
          &quot;resultId&quot;: 1234,
          &quot;resultProperty1&quot;: &quot;asdf&quot;
        }
      ]
    }
  }
  </code></pre>
  <p>I'm having issues referencing the inner array. I have tried queries like:</p>
  <pre><code>SEARCH / AS @RES results / WHERE([0]='someProperty'] @RES FROM ?
  SELECT * FROM (SELECT [1]-&gt;results AS results FROM ? WHERE [0] = 'someProperty')
  </code></pre>
  <p>But it's either pulling all of the inner array results, or none of them. Selecting and organising the object's fields into the results is also proving difficult.</p>
  <p>So far my closest attempt is:</p>
  <pre><code>SEARCH / AS @RES results / WHERE(resultId=1234) RETURN (resultId AS `results-&gt;resultId`, resultProperty1 AS `results-&gt;resultId`) FROM ?
  </code></pre>
  <p>Which is returning</p>
  <pre><code>[
    {
      &quot;results&quot;: {
        &quot;resultId&quot;: 1234,
        &quot;resultProperty1&quot;: &quot;asdf&quot;
    }
  ]
  </code></pre>