<!DOCTYPE html>
<html>

  <head>
    <script src="https://cdn.jsdelivr.net/alasql/0.3.1/alasql.min.js" data-require="alasql@0.3.1" data-semver="0.3.1"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js" data-require="jquery@3.1.1" data-semver="3.1.1"></script>
    <link href="style.css" rel="stylesheet" />
    <script src="script.js"></script>
  </head>

  <body>
    <label>Source JSON:
        <textarea name="json_src" id="json_src" rows="15" cols="50"></textarea>
    </label>
    <p>Click link to run query:</p>
    <ol>
      <li><a href="javascript:void(0);">SEARCH / WHERE (weight=3) FROM ?</a></li>
      <li><a href="javascript:void(0);">SEARCH /// WHERE (categoryName="belt") AND (categoryValue="purple") FROM ?</a></li>
      <li><a href="javascript:void(0);">SEARCH /categories/ WHERE (categoryName="belt") AND (categoryValue="purple") FROM ?</a></li>
      <li><a href="javascript:void(0);">SEARCH /categories/ WHERE (categoryName="belt") categoryValue FROM ?</a></li>
      <li><a href="javascript:void(0);">SEARCH / as @skill categories/ WHERE (categoryName="belt") AND (categoryValue="purple") @skill FROM ?</a></li>
      <li><a href="javascript:void(0);">SEARCH DISTINCT(/categories/ WHERE (categoryName="belt") categoryValue) FROM ?</a></li>
      <li><a href="javascript:void(0);">SEARCH DISTINCT(/ as @skill categories/ WHERE (categoryName="belt") AND (categoryValue="brown-black") @skill->weight) ORDER BY(DESC) FROM ?</a></li>
    </ol>
    <p>Result:</p>
    <div id="result"></div>
  </body>

</html>
$(document).ready(function() {
  $('li').click(
    function() {
      var result=alasql($(this).text(), [JSON.parse($('#json_src').val())]);
      result = '<pre>'+JSON.stringify(result, null, ' ')+'</pre>'
      $('#result').html(result);
    }
  );

  $('#json_src').val(JSON.stringify(
    [{
  "categories": [{
    "categoryName": "belt",
    "categoryValue": "white"
  }, {"categoryName": "level", "categoryValue": "Beginner"}, {
    "categoryName": "type",
    "categoryValue": "technique"
  }], "id": 1, "skillName": "Beginner 1", "skips": 0, "weight": 1
}, {
  "categories": [{"categoryName": "belt", "categoryValue": "white"}, {
    "categoryName": "level",
    "categoryValue": "Beginner"
  }, {"categoryName": "type", "categoryValue": "technique"}],
  "id": 2,
  "skillName": "Beginner 2",
  "skips": 0,
  "weight": 1
}, {
  "categories": [{"categoryName": "belt", "categoryValue": "white"}, {
    "categoryName": "level",
    "categoryValue": "Beginner"
  }, {"categoryName": "type", "categoryValue": "technique"}],
  "id": 3,
  "skillName": "Beginner 3",
  "skips": 0,
  "weight": 1
}, {
  "categories": [{"categoryName": "belt", "categoryValue": "white"}, {
    "categoryName": "level",
    "categoryValue": "Beginner"
  }, {"categoryName": "type", "categoryValue": "technique"}],
  "id": 4,
  "skillName": "Beginner 4",
  "skips": 0,
  "weight": 1
}, {
  "categories": [{"categoryName": "belt", "categoryValue": "white"}, {
    "categoryName": "level",
    "categoryValue": "Beginner"
  }, {"categoryName": "belt", "categoryValue": "technique"}],
  "id": 5,
  "skillName": "Beginner 5",
  "skips": 0,
  "weight": 1
}, {
  "categories": [{"categoryName": "belt", "categoryValue": "white"}, {
    "categoryName": "level",
    "categoryValue": "Beginner"
  }, {"categoryName": "type", "categoryValue": "technique"}],
  "id": 6,
  "skillName": "Beginner 6",
  "skips": 0,
  "weight": 1
}, {
  "categories": [{"categoryName": "belt", "categoryValue": "white"}, {
    "categoryName": "level",
    "categoryValue": "Beginner"
  }, {"categoryName": "type", "categoryValue": "technique"}],
  "id": 7,
  "skillName": "Beginner 7",
  "skips": 0,
  "weight": 1
}, {
  "categories": [{"categoryName": "belt", "categoryValue": "white"}, {
    "categoryName": "level",
    "categoryValue": "Beginner"
  }, {"categoryName": "type", "categoryValue": "technique"}],
  "id": 8,
  "skillName": "Beginner 8",
  "skips": 0,
  "weight": 1
}, {
  "categories": [{"categoryName": "belt", "categoryValue": "white"}, {
    "categoryName": "level",
    "categoryValue": "Beginner"
  }, {"categoryName": "type", "categoryValue": "technique"}],
  "id": 9,
  "skillName": "Beginner 9",
  "skips": 0,
  "weight": 1
}, {
  "categories": [{"categoryName": "belt", "categoryValue": "white"}, {
    "categoryName": "level",
    "categoryValue": "Beginner"
  }, {"categoryName": "type", "categoryValue": "technique"}],
  "id": 10,
  "skillName": "Beginner 10",
  "skips": 0,
  "weight": 1
}, {
  "categories": [{"categoryName": "belt", "categoryValue": "orange"}, {
    "categoryName": "level",
    "categoryValue": "Intermediate"
  }, {"categoryName": "type", "categoryValue": "technique"}],
  "id": 11,
  "skillName": "Intermediate 1",
  "skips": 0,
  "weight": 1
}, {
  "categories": [{"categoryName": "belt", "categoryValue": "orange"}, {
    "categoryName": "level",
    "categoryValue": "Intermediate"
  }, {"categoryName": "type", "categoryValue": "technique"}],
  "id": 12,
  "skillName": "Intermediate 2",
  "skips": 0,
  "weight": 1
}, {
  "categories": [{"categoryName": "belt", "categoryValue": "orange"}, {
    "categoryName": "level",
    "categoryValue": "Intermediate"
  }, {"categoryName": "type", "categoryValue": "technique"}],
  "id": 13,
  "skillName": "Intermediate 3",
  "skips": 0,
  "weight": 1
}, {
  "categories": [{"categoryName": "belt", "categoryValue": "orange"}, {
    "categoryName": "level",
    "categoryValue": "Intermediate"
  }, {"categoryName": "type", "categoryValue": "technique"}],
  "id": 14,
  "skillName": "Intermediate 4",
  "skips": 0,
  "weight": 1
}, {
  "categories": [{"categoryName": "belt", "categoryValue": "orange"}, {
    "categoryName": "level",
    "categoryValue": "Intermediate"
  }, {"categoryName": "type", "categoryValue": "technique"}],
  "id": 15,
  "skillName": "Intermediate 5",
  "skips": 0,
  "weight": 1
}, {
  "categories": [{"categoryName": "belt", "categoryValue": "purple"}, {
    "categoryName": "level",
    "categoryValue": "Intermediate"
  }, {"categoryName": "type", "categoryValue": "technique"}],
  "id": 16,
  "skillName": "Intermediate 6",
  "skips": 0,
  "weight": 1
}, {
  "categories": [{"categoryName": "belt", "categoryValue": "purple"}, {
    "categoryName": "level",
    "categoryValue": "Intermediate"
  }, {"categoryName": "type", "categoryValue": "technique"}],
  "id": 17,
  "skillName": "Intermediate 7",
  "skips": 0,
  "weight": 1
}, {
  "categories": [{"categoryName": "belt", "categoryValue": "purple"}, {
    "categoryName": "level",
    "categoryValue": "Intermediate"
  }, {"categoryName": "type", "categoryValue": "technique"}],
  "id": 18,
  "skillName": "Intermediate 8",
  "skips": 0,
  "weight": 1
}, {
  "categories": [{"categoryName": "belt", "categoryValue": "purple"}, {
    "categoryName": "level",
    "categoryValue": "Intermediate"
  }, {"categoryName": "type", "categoryValue": "technique"}],
  "id": 19,
  "skillName": "Intermediate 9",
  "skips": 0,
  "weight": 1
}, {
  "categories": [{"categoryName": "belt", "categoryValue": "purple"}, {
    "categoryName": "level",
    "categoryValue": "Intermediate"
  }, {"categoryName": "type", "categoryValue": "technique"}],
  "id": 20,
  "skillName": "Intermediate 10",
  "skips": 0,
  "weight": 2
}, {
  "categories": [{"categoryName": "belt", "categoryValue": "blue"}, {
    "categoryName": "level",
    "categoryValue": "Intermediate"
  }, {"categoryName": "type", "categoryValue": "technique"}],
  "id": 21,
  "skillName": "Intermediate 11",
  "skips": 0,
  "weight": 2
}, {
  "categories": [{"categoryName": "belt", "categoryValue": "blue"}, {
    "categoryName": "level",
    "categoryValue": "Intermediate"
  }, {"categoryName": "type", "categoryValue": "technique"}],
  "id": 22,
  "skillName": "Intermediate 12",
  "skips": 0,
  "weight": 2
}, {
  "categories": [{"categoryName": "belt", "categoryValue": "blue"}, {
    "categoryName": "level",
    "categoryValue": "Intermediate"
  }, {"categoryName": "type", "categoryValue": "technique"}],
  "id": 23,
  "skillName": "Intermediate 13",
  "skips": 0,
  "weight": 2
}, {
  "categories": [{"categoryName": "belt", "categoryValue": "blue"}, {
    "categoryName": "level",
    "categoryValue": "Intermediate"
  }, {"categoryName": "type", "categoryValue": "technique"}],
  "id": 24,
  "skillName": "Intermediate 14",
  "skips": 0,
  "weight": 2
}, {
  "categories": [{"categoryName": "belt", "categoryValue": "blue"}, {
    "categoryName": "level",
    "categoryValue": "Intermediate"
  }, {"categoryName": "type", "categoryValue": "technique"}],
  "id": 25,
  "skillName": "Intermediate 15",
  "skips": 0,
  "weight": 2
}, {
  "categories": [{"categoryName": "belt", "categoryValue": "green"}, {
    "categoryName": "level",
    "categoryValue": "Advanced"
  }, {"categoryName": "type", "categoryValue": "technique"}],
  "id": 26,
  "skillName": "Advanced 1",
  "skips": 0,
  "weight": 3
}, {
  "categories": [{"categoryName": "belt", "categoryValue": "green"}, {
    "categoryName": "level",
    "categoryValue": "Advanced"
  }, {"categoryName": "type", "categoryValue": "technique"}],
  "id": 27,
  "skillName": "Advanced 2",
  "skips": 0,
  "weight": 3
},
  {
    "categories": [{"categoryName": "belt", "categoryValue": "green"}, {
      "categoryName": "level",
      "categoryValue": "Advanced"
    }, {"categoryName": "type", "categoryValue": "technique"}],
    "id": 28,
    "skillName": "Advanced 3",
    "skips": 0,
    "weight": 3
  }, {
    "categories": [{"categoryName": "belt", "categoryValue": "green"}, {
      "categoryName": "level",
      "categoryValue": "Advanced"
    }, {"categoryName": "type", "categoryValue": "technique"}],
    "id": 29,
    "skillName": "Advanced 4",
    "skips": 0,
    "weight": 3
  }, {
    "categories": [{"categoryName": "belt", "categoryValue": "green"}, {
      "categoryName": "level",
      "categoryValue": "Advanced"
    }, {"categoryName": "type", "categoryValue": "technique"}],
    "id": 30,
    "skillName": "Advanced 5",
    "skips": 0,
    "weight": 3
  }, {
    "categories": [{"categoryName": "belt", "categoryValue": "brown"}, {
      "categoryName": "level",
      "categoryValue": "Advanced"
    }, {"categoryName": "type", "categoryValue": "technique"}],
    "id": 31,
    "skillName": "Advanced 6",
    "skips": 0,
    "weight": 4
  }, {
    "categories": [{"categoryName": "belt", "categoryValue": "brown"}, {
      "categoryName": "level",
      "categoryValue": "Advanced"
    }, {"categoryName": "type", "categoryValue": "technique"}],
    "id": 32,
    "skillName": "Advanced 7",
    "skips": 0,
    "weight": 4
  },
  {
    "categories": [{"categoryName": "belt", "categoryValue": "brown"}, {
      "categoryName": "level",
      "categoryValue": "Advanced"
    }, {"categoryName": "type", "categoryValue": "technique"}],
    "id": 33,
    "skillName": "Advanced 8",
    "skips": 0,
    "weight": 4
  }, {
    "categories": [{"categoryName": "belt", "categoryValue": "brown"}, {
      "categoryName": "level",
      "categoryValue": "Advanced"
    }, {"categoryName": "type", "categoryValue": "technique"}],
    "id": 34,
    "skillName": "Advanced 9",
    "skips": 0,
    "weight": 4
  }, {
    "categories": [{"categoryName": "belt", "categoryValue": "brown"}, {
      "categoryName": "level",
      "categoryValue": "Advanced"
    }, {"categoryName": "type", "categoryValue": "technique"}],
    "id": 35,
    "skillName": "Advanced 10",
    "skips": 0,
    "weight": 4
  }, {
    "categories": [{"categoryName": "belt", "categoryValue": "brown-black"}, {
      "categoryName": "level",
      "categoryValue": "Advanced"
    }, {"categoryName": "type", "categoryValue": "technique"}],
    "id": 36,
    "skillName": "Advanced 11",
    "skips": 0,
    "weight": 5
  },
  {
    "categories": [{"categoryName": "belt", "categoryValue": "brown-black"}, {
      "categoryName": "level",
      "categoryValue": "Advanced"
    }, {"categoryName": "type", "categoryValue": "technique"}],
    "id": 37,
    "skillName": "Advanced 12",
    "skips": 0,
    "weight": 5
  }, {
    "categories": [{"categoryName": "belt", "categoryValue": "brown-black"}, {
      "categoryName": "level",
      "categoryValue": "Advanced"
    }, {"categoryName": "type", "categoryValue": "technique"}],
    "id": 38,
    "skillName": "Advanced 13",
    "skips": 0,
    "weight": 5
  }, {
    "categories": [{"categoryName": "belt", "categoryValue": "brown-black"}, {
      "categoryName": "level",
      "categoryValue": "Advanced"
    }, {"categoryName": "type", "categoryValue": "technique"}],
    "id": 39,
    "skillName": "Advanced 14",
    "skips": 0,
    "weight": 5
  }, {
    "categories": [{"categoryName": "belt", "categoryValue": "brown-black"}, {
      "categoryName": "level",
      "categoryValue": "Advanced"
    }, {"categoryName": "type", "categoryValue": "technique"}],
    "id": 40,
    "skillName": "Advanced 15",
    "skips": 0,
    "weight": 5
  },
  {
    "categories": [{"categoryName": "belt", "categoryValue": "white"}, {
      "categoryName": "level",
      "categoryValue": "Beginner"
    }, {"categoryName": "type", "categoryValue": "form"}],
    "id": 41,
    "skillName": "Short 0",
    "skips": 0,
    "weight": 1
  }, {
    "categories": [{"categoryName": "belt", "categoryValue": "white"}, {
      "categoryName": "level",
      "categoryValue": "Beginner"
    }, {"categoryName": "type", "categoryValue": "form"}],
    "id": 42,
    "skillName": "Short 1",
    "skips": 0,
    "weight": 1
  },
  {
    "categories": [{"categoryName": "belt", "categoryValue": "purple"}, {
      "categoryName": "level",
      "categoryValue": "Intermediate"
    }, {"categoryName": "type", "categoryValue": "form"}],
    "id": 43,
    "skillName": "Short 2",
    "skips": 0,
    "weight": 3
  }, {
    "categories": [{"categoryName": "belt", "categoryValue": "blue"}, {
      "categoryName": "level",
      "categoryValue": "Intermediate"
    }, {"categoryName": "type", "categoryValue": "form"}],
    "id": 44,
    "skillName": "Short 3",
    "skips": 0,
    "weight": 3
  },
  {
    "categories": [{"categoryName": "belt", "categoryValue": "orange"}, {
      "categoryName": "level",
      "categoryValue": "Intermediate"
    }, {"categoryName": "type", "categoryValue": "form"}],
    "id": 45,
    "skillName": "Long 1",
    "skips": 0,
    "weight": 4
  }, {
    "categories": [{"categoryName": "belt", "categoryValue": "white"}, {
      "categoryName": "level",
      "categoryValue": "Beginner"
    }, {"categoryName": "type", "categoryValue": "form"}],
    "id": 46,
    "skillName": "Stance Set 1",
    "skips": 0,
    "weight": 2
  }, {
    "categories": [{"categoryName": "belt", "categoryValue": "brown"}, {
      "categoryName": "level",
      "categoryValue": "Advanced"
    }, {"categoryName": "type", "categoryValue": "form"}],
    "id": 47,
    "skillName": "Stance Set 2",
    "skips": 0,
    "weight": 4
  }, {
    "categories": [{"categoryName": "belt", "categoryValue": "white"}, {
      "categoryName": "level",
      "categoryValue": "Beginner"
    }, {"categoryName": "type", "categoryValue": "form"}],
    "id": 48,
    "skillName": "Blocking Set",
    "skips": 0,
    "weight": 1
  }, {
    "categories": [{"categoryName": "belt", "categoryValue": "white"}, {
      "categoryName": "level",
      "categoryValue": "Beginner"
    }, {"categoryName": "type", "categoryValue": "form"}],
    "id": 49,
    "skillName": "Star Blocks",
    "skips": 0,
    "weight": 1
  }, {
    "categories": [{"categoryName": "belt", "categoryValue": "white"}, {
      "categoryName": "level",
      "categoryValue": "Beginner"
    }, {"categoryName": "type", "categoryValue": "form"}],
    "id": 50,
    "skillName": "Triple Ridge Hand Set",
    "skips": 0,
    "weight": 1
  },
  {
    "categories": [{"categoryName": "belt", "categoryValue": "purple"}, {
      "categoryName": "level",
      "categoryValue": "Intermediate"
    }, {"categoryName": "type", "categoryValue": "form"}],
    "id": 51,
    "skillName": "Striking Set",
    "skips": 0,
    "weight": 2
  },
  {
    "categories": [{"categoryName": "belt", "categoryValue": "purple"}, {
      "categoryName": "level",
      "categoryValue": "Intermediate"
    }, {"categoryName": "type", "categoryValue": "form"}],
    "id": 52,
    "skillName": "Double Ram",
    "skips": 0,
    "weight": 3
  },
  {
    "categories": [{"categoryName": "belt", "categoryValue": "green"}, {
      "categoryName": "level",
      "categoryValue": "Advanced"
    }, {"categoryName": "type", "categoryValue": "form"}],
    "id": 53,
    "skillName": "Staff Set",
    "skips": 0,
    "weight": 3
  }, {
    "categories": [{"categoryName": "belt", "categoryValue": "brown"}, {
      "categoryName": "level",
      "categoryValue": "Advanced"
    }, {"categoryName": "type", "categoryValue": "form"}],
    "id": 54,
    "skillName": "Book Set",
    "skips": 0,
    "weight": 3
  }, {
    "categories": [{"categoryName": "belt", "categoryValue": "brown-black"}, {
      "categoryName": "level",
      "categoryValue": "Advanced"
    }, {"categoryName": "type", "categoryValue": "form"}],
    "id": 55,
    "skillName": "Black Belt Set",
    "skips": 0,
    "weight": 4
  }, {
    "categories": [{"categoryName": "belt", "categoryValue": "orange"}, {
      "categoryName": "level",
      "categoryValue": "Intermediate"
    }, {"categoryName": "type", "categoryValue": "sparring"}],
    "id": 56,
    "skillName": "Jammers Backknuckle",
    "skips": 0,
    "weight": 1
  }, {
    "categories": [{"categoryName": "belt", "categoryValue": "purple"}, {
      "categoryName": "level",
      "categoryValue": "Intermediate"
    }, {"categoryName": "type", "categoryValue": "sparring"}],
    "id": 57,
    "skillName": "Jammers 1-2-3",
    "skips": 0,
    "weight": 2
  }, {
    "categories": [{"categoryName": "belt", "categoryValue": "blue"}, {
      "categoryName": "level",
      "categoryValue": "Intermediate"
    }, {"categoryName": "type", "categoryValue": "sparring"}],
    "id": 58,
    "skillName": "Blockers",
    "skips": 0,
    "weight": 2
  }, {
    "categories": [{"categoryName": "belt", "categoryValue": "green"}, {
      "categoryName": "level",
      "categoryValue": "Advanced"
    }, {"categoryName": "type", "categoryValue": "sparring"}],
    "id": 59,
    "skillName": "Runners",
    "skips": 0,
    "weight": 3
  }]))
  
});
textarea, input {
  vertical-align:top;
}
#result {
  width:400px;
  background-color: #FFC;
}
ol{
  padding-left:1.2em;
}
li {
  margin-bottom:.5em;
}

li a,
li a:visited{
  text-decoration:none;
  color:#000;
  background-color: #CEF;
  padding:.3em;
  border-radius:.3em;
  display:block;
}

li a:hover{
  background-color:#9CF;
  text-decoration:none;
}
AlaSQL JSON SEARCH syntax samples