Project:SPARQL/examples: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
No edit summary
Line 244: Line 244:
   ?item wdt:P72 ?author1 . # Selects a first author.
   ?item wdt:P72 ?author1 . # Selects a first author.
   ?item wdt:P72 ?author2 . # Selects a second author.
   ?item wdt:P72 ?author2 . # Selects a second author.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } # Helps get the label in your language, if not, then en (English) language
}
</sparql>
==== Subject clustering ====
This query returns a graph of subjects (P134: indexing concept, P135: subject, P136: key concept, and P206: MeSH subject) which are listed alongside one another. It uses the service wikibase:label to return the labels in your default language or in English. WARNING: Be extremely careful with this query as it will take several minutes to run or may crash. Use at your own risk.
<sparql tryit="1">PREFIX wd: <https://lgbtdb.wikibase.cloud/entity/>
PREFIX wdt: <https://lgbtdb.wikibase.cloud/prop/direct/>
#defaultView:Graph
SELECT ?subject1 ?subject1Label ?subject2 ?subject2Label {
  ?item wdt:P134*/wdt:135*/wdt:P136*/wdt:P206* ?subject1. # Selects a first subject.
  ?item wdt:P134*/wdt:135*/wdt:P136*/wdt:P206* ?subject2 . # Selects a second subject.
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } # Helps get the label in your language, if not, then en (English) language
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } # Helps get the label in your language, if not, then en (English) language
}
}

Navigation menu