Skip to main content

Analytical Queries - Example

Take a look at the below query.

{  "select": "?nums",  "where": [    // Clause 1    ["$fdb", ["person/handle", "zsmith"], "person/favNums", "?nums"],
    // Clause 2    ["$fdb", ["person/handle", "jdoe"], "person/favNums", "?nums"]  ]}
/* Note: In this query, select is not in an array. When selecting only one variable, we can omit the hard brackets */

The source for both of the clauses is $fdb - the current Fluree.

The first clause has a subject of ["person/handle", "zsmith"], and the second clause has a subject of "person/handle", "jdoe"]. Both clauses are referring to a different person.

The predicate for both clauses is person/favNums.

The object for both clauses is a variable, ?nums. Remember, that when two clauses include the same variable, then we only keep values that satisfy ALL flake patterns.