Search code examples
sparqldbpedia

Query SPARQL doesn't work with "dct:subject"


SELECT ?name ?birth  ?person ?subject 

WHERE {      ?person dbo:birthPlace :London .      ?person 

dbo:birthDate ?birth .      ?person foaf:name ?name .  

?person dct:subject :English_rock_singers. ?person dct:subject ?

subject.   } ORDER BY ?name

This query works only if I delete the "subject". Is there a way to query dbpedia with a category?


Solution

  • Though your question is not clear, I think your problem is with formatting the query and defining the prefixes. This should work:

    PREFIX dbo: <http://dbpedia.org/ontology/>
    PREFIX foaf: <http://xmlns.com/foaf/0.1/>
    PREFIX dct: <http://purl.org/dc/terms/>
    PREFIX dbr: <http://dbpedia.org/resource/>
    PREFIX dbc: <http://dbpedia.org/resource/Category:>
    
    SELECT ?name ?birth ?person ?subject WHERE {
    
      ?person dbo:birthPlace dbr:London.
      ?person dbo:birthDate ?birth.    
      ?person foaf:name ?name.  
      ?person dct:subject dbc:English_rock_singers.  
      ?person dct:subject ?subject.   
    } 
    ORDER BY ?name