SPARQL Examples – Limit
Posted on Aug 31, 2017 (last modified Jun 23, 2021)
Limit the number of results returned
PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
PREFIX bc: <http://www.base22.com/ontologies/2010/5/bc.owl#>
SELECT *
WHERE {
?subject bc:hasEmployer <http://www.base22.com/ontologies/2010/5/my-contacts.owl#IBM> .
?subject bc:hasBusinessEmail ?email .
} LIMIT 5
The LIMIT
keyword is used after the WHERE
clause, followed by a numerical value. In this case, of course, only 5 results are returned.
LIMIT
is a solution modifier that limits the number of rows returned from a query. SPARQL has two other solution modifiers:ORDER BY
for sorting query solutions on the value of one or more variablesOFFSET
, used in conjunction withLIMIT
andORDER BY
to take a slice of a sorted solution set (e.g. for paging)