core: ensure query works for multiple criteria
core: add `ORDER BY id" clause to the query