 
				Data
<http://example.org/book/book1> <http://purl.org/dc/elements/1.1/title> "SPARQL Tutorial" . Query
SELECT ?title
WHERE
{
  <http://example.org/book/book1> <http://purl.org/dc/elements/1.1/title> ?title .
}Result
| title | 
|---|
| SPARQL Tutorial | 
Data
@prefix foaf:  <http://xmlns.com/foaf/0.1/> .
_:a  foaf:name   "Johnny Lee Outlaw" .
_:a  foaf:mbox   <mailto:jlow@example.com> .
_:b  foaf:name   "Peter Goodguy" .
_:b  foaf:mbox   <mailto:peter@example.org> .
_:c  foaf:mbox   <mailto:carol@example.org> .Query
PREFIX foaf:   <http://xmlns.com/foaf/0.1/>
SELECT ?name ?mbox
WHERE
  { ?x foaf:name ?name .
    ?x foaf:mbox ?mbox }Result
| name | mbox | 
|---|---|
| "Johnny Lee Outlaw" | <mailto:jlow@example.com> | 
| "Peter Goodguy" | <mailto:peter@example.org> | 
Data
@prefix dc:   <http://purl.org/dc/elements/1.1/> .
@prefix :     <http://example.org/book/> .
@prefix ns:   <http://example.org/ns#> .
:book1  dc:title  "SPARQL Tutorial" .
:book1  ns:price  42 .
:book1  ns:discount 0.2 .
:book2  dc:title  "The Semantic Web" .
:book2  ns:price  23 .
:book2  ns:discount 0.25 .Query
PREFIX  dc:  <http://purl.org/dc/elements/1.1/>
PREFIX  ns:  <http://example.org/ns#>
SELECT  ?title (?p*(1-?discount) AS ?price)
{ ?x ns:price ?p .
  ?x dc:title ?title . 
  ?x ns:discount ?discount 
}Result
| title | price | 
|---|---|
| "The Semantic Web" | 17.25 | 
| "SPARQL Tutorial" | 33.6 | 
Data
@prefix org:    <http://example.com/ns#> .
_:a  org:employeeName   "Alice" .
_:a  org:employeeId     12345 .
_:b  org:employeeName   "Bob" .
_:b  org:employeeId     67890 .Query
PREFIX foaf:   <http://xmlns.com/foaf/0.1/>
PREFIX org:    <http://example.com/ns#>
CONSTRUCT { ?x foaf:name ?name }
WHERE  { ?x org:employeeName ?name }Result
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
      
_:x foaf:name "Alice" .
_:y foaf:name "Bob" .Data
@prefix  foaf:  <http://xmlns.com/foaf/0.1/> .
_:a    foaf:name   "Alice" .
_:a    foaf:mbox   <mailto:alice@example.org> .Query
PREFIX foaf:    <http://xmlns.com/foaf/0.1/>
PREFIX vcard:   <http://www.w3.org/2001/vcard-rdf/3.0#>
CONSTRUCT   { <http://example.org/person#Alice> vcard:FN ?name }
WHERE       { ?x foaf:name ?name }Result
@prefix vcard: <http://www.w3.org/2001/vcard-rdf/3.0#> .
<http://example.org/person#Alice> vcard:FN "Alice" .Data
@prefix dc:   <http://purl.org/dc/elements/1.1/> .
@prefix :     <http://example.org/book/> .
@prefix ns:   <http://example.org/ns#> .
:book1  dc:title  "SPARQL Tutorial" .
:book1  ns:price  42 .
:book2  dc:title  "The Semantic Web" .
:book2  ns:price  23 .Query
PREFIX  dc:  <http://purl.org/dc/elements/1.1/>
SELECT  ?title
WHERE   { ?x dc:title ?title
          FILTER regex(?title, "^SPARQL") 
        }Result
| title | 
|---|
| "SPARQL Tutorial" | 
Query
PREFIX  dc:  <http://purl.org/dc/elements/1.1/>
SELECT  ?title
WHERE   { ?x dc:title ?title
          FILTER regex(?title, "web", "i" ) 
        }Result
| title | 
|---|
| "The Semantic Web" | 
Data
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
_:a  rdf:type        foaf:Person .
_:a  foaf:name       "Alice" .
_:a  foaf:mbox       <mailto:alice@example.com> .
_:a  foaf:mbox       <mailto:alice@work.example> .
_:b  rdf:type        foaf:Person .
_:b  foaf:name       "Bob" .Query
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?name ?mbox
WHERE  { ?x foaf:name  ?name .
         OPTIONAL { ?x  foaf:mbox  ?mbox }
       }Result
| name | mbox | 
|---|---|
| "Alice" | <mailto:alice@example.com> | 
| "Alice" | <mailto:alice@work.example> | 
| "Bob" | 
Data
@prefix dc:   <http://purl.org/dc/elements/1.1/> .
@prefix :     <http://example.org/book/> .
@prefix ns:   <http://example.org/ns#> .
:book1  dc:title  "SPARQL Tutorial" .
:book1  ns:price  42 .
:book2  dc:title  "The Semantic Web" .
:book2  ns:price  23 .Query
PREFIX  dc:  <http://purl.org/dc/elements/1.1/>
PREFIX  ns:  <http://example.org/ns#>
SELECT  ?title ?price
WHERE   { ?x dc:title ?title .
          OPTIONAL { ?x ns:price ?price . FILTER (?price < 30) }
        }Result
| title | price | 
|---|---|
| "SPARQL Tutorial" | |
| "The Semantic Web" | 23 | 
Data
@prefix foaf:       <http://xmlns.com/foaf/0.1/> .
_:a  foaf:name       "Alice" .
_:a  foaf:homepage   <http://work.example.org/alice/> .
_:b  foaf:name       "Bob" .
_:b  foaf:mbox       <mailto:bob@work.example> .Query
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?name ?mbox ?hpage
WHERE  { ?x foaf:name  ?name .
         OPTIONAL { ?x foaf:mbox ?mbox } .
         OPTIONAL { ?x foaf:homepage ?hpage }
       }Result
| name | mbox | hpage | 
|---|---|---|
| "Alice" | <http://work.example.org/alice/> | |
| "Bob" | <mailto:bob@work.example> | 
Data
@prefix : <http://books.example/> .
:org1 :affiliates :auth1, :auth2 .
:auth1 :writesBook :book1, :book2 .
:book1 :price 9 .
:book2 :price 5 .
:auth2 :writesBook :book3 .
:book3 :price 7 .
:org2 :affiliates :auth3 .
:auth3 :writesBook :book4 .
:book4 :price 7 .Query
PREFIX : <http://books.example/>
SELECT ?org (SUM(?lprice) AS ?totalPrice)
WHERE {
  ?org :affiliates ?auth .
  ?auth :writesBook ?book .
  ?book :price ?lprice .
}
GROUP BY ?org
HAVING (SUM(?lprice) > 10)Result
| org | totalPrice | 
|---|---|
| org1 | 21 | 
Data
@prefix : <http://org.example/> .
:org1 :affiliates :p1, :p2, :p6 .
:org2 :affiliates :p3, :p4 .
:p1 :name "John" .
:p2 :name "Paul" .
:p6 :name "John" .
:p3 :name "Ringo" .
:p4 :name "George" .Query
PREFIX : <http://books.example/>
SELECT ?org (GROUP_CONCAT(DISTINCT ?name;separator=', ') as ?names)
WHERE {?org :affiliates ?p. ?p :name ?name }
GROUP BY ?orgResult
| org | names | 
|---|---|
| org1 | "John, Paul" | 
| org2 | "Ringo, George" | 
{ :book1 dc:title|rdfs:label ?displayString }{
    ?x foaf:mbox <mailto:alice@example> .
    ?x foaf:knows/foaf:name ?name .
}{ 
    ?x foaf:mbox <mailto:alice@example> .
    ?x foaf:knows/foaf:knows/foaf:name ?name .
}This is the same as the SPARQL query:
SELECT ?x ?name
{
    ?x  foaf:mbox <mailto:alice@example> .
    ?x  foaf:knows ?a1 .
    ?a1 foaf:knows ?a2 .
    ?a2 foaf:name ?name .
}{ ?x foaf:mbox <mailto:alice@example> .
    ?x foaf:knows/foaf:knows ?y .
    FILTER ( ?x != ?y )
    ?y foaf:name ?name 
}{ ?x foaf:mbox <mailto:alice@example> }{ <mailto:alice@example> ^foaf:mbox ?x }{
    ?x foaf:knows/^foaf:knows ?y .  
    FILTER(?x != ?y)
}This is the same as the SPARQL query:
{
    ?x foaf:knows ?a .
    ?y foaf:knows ?a .  
    FILTER(?x != ?y)
}{
    ?x foaf:mbox <mailto:alice@example> .
    ?x foaf:knows+/foaf:name ?name .
}{ ?ancestor (ex:motherOf|ex:fatherOf)+ <#me> }{ ?x rdf:type/rdfs:subClassOf* ?type }{ ?x ?p ?v . ?p rdfs:subPropertyOf* :property }{ ?x !(rdf:type|^rdf:type) ?y }{ :list rdf:rest*/rdf:first ?element }Data
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
	_:a  foaf:name       "Alice" .
	_:a  foaf:homepage   <http://work.example.org/alice/> .
	_:b  foaf:name       "Bob" .
	_:b  foaf:mbox       <mailto:bob@work.example> .Query
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
	ASK  { ?x foaf:name  "Alice" }Result
trueQuery
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
ASK  { ?x foaf:name  "Alice" ;
          foaf:mbox  <mailto:alice@work.example> }Result
falseDESCRIBE <http://example.org/>PREFIX foaf: <http://xmlns.com/foaf/0.1/>
	DESCRIBE ?x
	WHERE    { ?x foaf:name "Alice" }Query
PREFIX ent:  <http://org.example.com/employees#>
DESCRIBE ?x WHERE { ?x ent:employeeId "1234" }Result
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix vcard:  <http://www.w3.org/2001/vcard-rdf/3.0> .
@prefix exOrg:  <http://org.example.com/employees#> .
@prefix rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix owl:  <http://www.w3.org/2002/07/owl#>
_:a     exOrg:employeeId    "1234" ;
       
        foaf:mbox_sha1sum   "bee135d3af1e418104bc42904596fe148e90f033" ;
        vcard:N
         [ vcard:Family       "Smith" ;
           vcard:Given        "John"  ] .
foaf:mbox_sha1sum  rdf:type  owl:InverseFunctionalProperty .Data
@prefix  :  <http://example/> .
@prefix  rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix  foaf:  <http://xmlns.com/foaf/0.1/> .
:alice  rdf:type   foaf:Person .
:alice  foaf:name  "Alice" .
:bob    rdf:type   foaf:Person .Query
PREFIX  rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#> 
PREFIX  foaf:  <http://xmlns.com/foaf/0.1/> 
SELECT ?person
WHERE 
{
    ?person rdf:type  foaf:Person .
    FILTER EXISTS { ?person foaf:name ?name }
}Result
| person | 
|---|
| <http://example/alice> | 
Data
@prefix  :  <http://example/> .
@prefix  rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix  foaf:  <http://xmlns.com/foaf/0.1/> .
:alice  rdf:type   foaf:Person .
:alice  foaf:name  "Alice" .
:bob    rdf:type   foaf:Person .Query
PREFIX  rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#> 
PREFIX  foaf:  <http://xmlns.com/foaf/0.1/> 
SELECT ?person
WHERE 
{
    ?person rdf:type  foaf:Person .
    FILTER NOT EXISTS { ?person foaf:name ?name }
}Result
| person | 
|---|
| <http://example/bob> | 
Data
@prefix  :  <http://example/> .
@prefix  foaf:  <http://xmlns.com/foaf/0.1/> .
:alice  foaf:givenName "Alice" ;
        foaf:familyName "Smith" .
:bob    foaf:givenName "Bob" ;
        foaf:familyName "Jones" .
:carol  foaf:givenName "Carol" ;
        foaf:familyName "Smith" .Query
PREFIX :  <http://example/> 
PREFIX  foaf:  <http://xmlns.com/foaf/0.1/> 
SELECT DISTINCT ?s
WHERE {
   ?s ?p ?o .
   MINUS {
      ?s foaf:givenName "Bob" .
   }
}Result
| s | 
|---|
| <http://example/carol> | 
| <http://example/alice> | 
Data
@prefix : <http://people.example/> .
:alice :name "Alice", "Alice Foo", "A. Foo" .
:alice :knows :bob, :carol .
:bob :name "Bob", "Bob Bar", "B. Bar" .
:carol :name "Carol", "Carol Baz", "C. Baz" .Query
PREFIX : <http://people.example/>
PREFIX : <http://people.example/>
SELECT ?y ?minName
WHERE {
  :alice :knows ?y .
  {
    SELECT ?y (MIN(?name) AS ?minName)
    WHERE {
      ?y :name ?name .
    } GROUP BY ?y
  }
}Results of inner query
| y | minName | 
|---|---|
| :alice | "A. Foo" | 
| :bob | "B. Bar" | 
| :carol | "C. Baz" | 
These are joined with the results of the outer query
| y | 
|---|
| :bob | 
| :carol | 
Final Result
| y | minName | 
|---|---|
| :bob | "B. Bar" | 
| :carol | "C. Baz" |