Search code examples
sparqlwikipediawikidata

Wikidata SPARQL query returns wrong results


This query, why does it return Gabriel Heinze and not Cristiano Ronaldo? Both satisfy the criteria

SELECT DISTINCT ?person ?personLabel WHERE {
  ?person wdt:P54 wd:Q18656.
  ?person wdt:P54 wd:Q75729.
  ?person wdt:P54 wd:Q8682.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}

Solution

  • Querying clubs Cristiano Ronaldo is member of, using wdt as property prefix returns only the Real Madrid FC as this statement has a higher priority rank, and wdt focuses on the highest priority rank statements.

    Unfortunatly, there is no direct substitute to wdt that would include lower priority statements, but you can use a combination of p and ps:

    Thanks for asking: researching, I finally learned what the t stands for in wdt: truthy \o/