Search code examples
sparqldbpedia

How to get information like capital, currency, language, population about a country in simple way using SPARQL from DBPEDIA


How to get information like capital, currency, language, population about a country in simple way using SPARQL from DBPEDIA. Is there a simple way to do it?


Solution

  • I found a solution for this problem, I figured out a query that returns all the required fields,

     SELECT DISTINCT ?country ?population ?capital ?currency WHERE {
       {?country rdf:type 
     <http://dbpedia.org/class/yago/WikicatMemberStatesOfTheUnitedNations> .
      ?country  <http://dbpedia.org/ontology/populationTotal> ?population .
      ?country  <http://dbpedia.org/ontology/capital> ?capital .
      ?country  <http://dbpedia.org/ontology/currency> ?currency .}
    UNION
      {?country rdf:type <http://dbpedia.org/ontology/Country> .
      ?country  <http://dbpedia.org/ontology/populationTotal> ?population .
      ?country  <http://dbpedia.org/ontology/capital> ?capital .
      ?country  <http://dbpedia.org/ontology/currency> ?currency .}
    }
    

    SPARQL Result