Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

250
Views
Filter sub arrays in AlaSQL

I have a Javascript object being passed into AlaSQL like:

const details = {
  "returnCode": 0,
  "someProperty": {
    "results": [
      {
        "resultId": 1234,
        "resultProperty1": "asdf",
        "notWantedProperty": "notThis",
        "anotherNotWantedProperty": "orAnyOther"
      },
      {
        "resultId": 5678,
        "resultProperty1": "qwert",
        "notWantedProperty": "notThisEither"
      }
    ]
  }
}
results = alasql(query, [details]);

I'm trying to use alasql to filter out like any of these with a WHERE query "resultProperty1 == "asdf" and get a result like:

{
  "returnCode": 0,
  "results": [
    {
      "resultId": 1234,
      "resultProperty1": "asdf"
    },
  ]
}
-- or --
{
  "returnCode": 0,
  "results": {
    "resultId": 1234,
    "resultProperty1": "asdf"
  }
}
-- or --
{
  "returnCode": 0,
  "someProperty": {
    "results": {
      "resultId": 1234,
      "resultProperty1": "asdf"
    }
  }
}
-- or --
{
  "returnCode": 0,
  "someProperty": {
    "results": [
      {
        "resultId": 1234,
        "resultProperty1": "asdf"
      }
    ]
  }
}

I'm having issues referencing the inner array. I have tried queries like:

SEARCH / AS @RES results / WHERE([0]='someProperty'] @RES FROM ?
SELECT * FROM (SELECT [1]->results AS results FROM ? WHERE [0] = 'someProperty')

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.

So far my closest attempt is:

SEARCH / AS @RES results / WHERE(resultId=1234) RETURN (resultId AS `results->resultId`, resultProperty1 AS `results->resultId`) FROM ?

Which is returning

[
  {
    "results": {
      "resultId": 1234,
      "resultProperty1": "asdf"
  }
]
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!