Your first SPARQL query
The simplest possible query
Here is a very simple SPARQL query:
$ sparql --data ../social.ttl --query simple.sparql
- query:
-
SELECT ?person WHERE { <http://elmonline.ca/luke> <http://xmlns.com/foaf/0.1/knows> ?person . }
- results:
-
---------------------------------------------------------- | person | ========================================================== | <http://www.linkedin.com/pub/matthew-links/44/381/647> | | <http://www.linkedin.com/pub/mark-wilkinson/1/674/665> | | <http://www.linkedin.com/in/mcourtot> | ----------------------------------------------------------
Prefixes
We can add URI prefixes to make the query easier to read:
$ sparql --data ../social.ttl --query prefix.sparql
- query:
-
PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT ?person WHERE { <http://elmonline.ca/luke> foaf:knows ?person . }
- results:
-
---------------------------------------------------------- | person | ========================================================== | <http://www.linkedin.com/pub/matthew-links/44/381/647> | | <http://www.linkedin.com/pub/mark-wilkinson/1/674/665> | | <http://www.linkedin.com/in/mcourtot> | ----------------------------------------------------------
But how did we know what URIs to use in our query?