is a query operator that can be applied to an RDFStore, which returns a list of associations of variables to corresponding values in subgraphs that match pattern.


returns values only for the variables vars.

Details and Options

  • SPARQLSelect can be used in SPARQLExecute to query a SPARQL endpoint.
  • The result of executing SPARQLSelect[pattern] is a list of associations {<|"var1"val1,1,|>,} where each "vari" is the name of a SPARQLVariable appearing in pattern and each vali,j is the value appearing in the corresponding position of a matching subgraph.
  • In SPARQLSelect[pattern], pattern can be any of the following forms:
  • RDFTriple[s,p,o]triple pattern
    {RDFTriple[],RDFTriple[],}basic graph pattern
    {patt1,patt2,}group graph pattern
    SPARQLFilter[expr]filter solutions of surrounding patterns by expr
    patt/;exprfilter solutions by expr
    SPARQLOptional[patt]optional pattern
    patt1|patt2|...union pattern
    Except[patt]eliminate solutions which are compatible with patt
    SPARQLPropertyPath[]property path pattern
    "var"exprbind expression expr to a variable with name "var"
    SPARQLValues[vars, values]specify values for variables
    SPARQLGraph[g,patt]match patt agains the graph with name g
    SPARQLService[url,patt]federate matching patt to the SPARQL endpoint located at url
  • In a triple pattern RDFTriple[s,p,o] a SPARQLVariable stands for any expression.
  • The following options can be given:
  • "Distinct"Falsewhether duplicate solutions are deleted
    "Limit"Infinitymaximum numer of solutions to return
    "Offset"0number of solutions to skip
    "OrderBy"Noneexpression by which solutions are ordered
    "Reduced"Falsewhether duplicate solutions can be deleted


open allclose all

Basic Examples  (2)

Data about fruits:

Find the color of fruits:

Find the color and the shape of fruits:

Find formulas (P274) and the Japanese name of chemicals (Q11173) containing (P527) calcium (Q706) in Wikidata:

Scope  (9)

Triple Pattern  (1)

Example data:

A triple pattern is a triple that can contain variables:

Variables can appear in any position:

A triple pattern does not need to contain any variables:

Basic Graph Pattern  (1)

Data about articles:

A basic graph pattern is a list of triple patterns. Retrieve "title" and "created" of all articles:

Variables and literals can appear in any position. Find authors of articles created in 2018:

Different triple patterns in a basic graph pattern are not required to match different triples in a graph. The following contains solutions binding "art1" and "art2" to the same article:

To find authors that have published more than one article filter the solution by requiring "art1" and "art2" to be different:

Filter  (1)

Data about books:

Books published before 1820:

Optional  (1)

Data about people:

Find the name and optionally the e-mail address of all people:

When the SPARQLOptional wrapper is omitted the solution for "Bob" is missing:

Union  (1)

Data about things, using different "name" properties:

Find the "name" of all things:

The same query using a property path:

Negation  (1)

Data about people:

Find people without e-mail address:

In this case a query based on NOT EXISTS gives the same result:

Property Paths  (1)

Family data:

Find descendents of Johann:

Find only grandchildren:

Assignment  (1)

Data about food products:

Look up the price including delivery fee:

The same query using a "select expression":

Filter products by total price:

Look up the price for certain products:

Aggregates  (1)

Data about salaries:

Find the average salary:

The average salary by department:

Filter the groups by the total department salary:

Order by decreasing average salary:

Neat Examples  (1)

Make a Graph of parent taxons (P171) of the Whale (Q42196) using Wikidata:

Wolfram Research (2019), SPARQLSelect, Wolfram Language function,


Wolfram Research (2019), SPARQLSelect, Wolfram Language function,


Wolfram Language. 2019. "SPARQLSelect." Wolfram Language & System Documentation Center. Wolfram Research.


Wolfram Language. (2019). SPARQLSelect. Wolfram Language & System Documentation Center. Retrieved from


@misc{reference.wolfram_2024_sparqlselect, author="Wolfram Research", title="{SPARQLSelect}", year="2019", howpublished="\url{}", note=[Accessed: 21-June-2024 ]}


@online{reference.wolfram_2024_sparqlselect, organization={Wolfram Research}, title={SPARQLSelect}, year={2019}, url={}, note=[Accessed: 21-June-2024 ]}