On Wikidata's SPARQL endpoint , I want to find all the universities where someone was employed as a university teacher. So far, I managed to get the triples of type (person, position helf, employer) with the following query:
PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX v: <http://www.wikidata.org/prop/statement/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
SELECT DISTINCT ?s ?sp ?q ?sLabel ?spLabel ?qLabel WHERE {
?s p:P39 ?p .
?p v:P39 ?sp .
?p pq:P108 ?q .
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en" .
}
}
This query returns all the positions held by that person. In my case, I want to limit myself to the held position of university teacher (wd:Q1622272).
If possible, I would ask for a simplified query.
Replace the variable ?sp
with the specific position you want (ie wd:Q1622272
) in the triple pattern ?pv:P39 ?sp .
:
PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX v: <http://www.wikidata.org/prop/statement/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
SELECT DISTINCT ?s ?q ?sLabel ?qLabel WHERE {
?s p:P39 ?p .
?p v:P39 wd:Q1622272 . # Here
?p pq:P108 ?q .
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en" .
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.