Your query isn't legal. If you paste it into sparql.org's query validator, you'll see the syntax error:
Input:
1 # Find US states, their capitals and largest cities 2 PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> 3 PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> 4 PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> 5 PREFIX dbpr: <http://dbpedia.org/resource/> 6 PREFIX dbpo: <http://dbpedia.org/ontology/> 7 PREFIX dbpprop: <http://dbpedia.org/property/> 8 9 #for all the capitols in the states 10 SELECT ?capitol 11 WHERE { 12 ?capitol dbpo:state ?country . 13 { ?capitol a dbpo:capitol } . 14 { ?country a dbpprop:country "U.S." } . 15 }
Syntax error:
Encountered " "\"U.S.\" "" at line 14, column 30. Was expecting one of: "values" ... "graph" ... "optional" ... "minus" ... "bind" ... "service" ... "filter" ... "{" ... "}" ... ";" ... "," ... "." ...
It looks like you're using DBpedia, and if that's the case, then you can this a query like this at the DBpedia public endpoint. (The variable ?state
is a bit of a misnomer; there are 56 results.)
select ?state ?capital where {
?state dbpedia-owl:capital ?capital ;
dbpedia-owl:country dbpedia:United_States .
}