I am trying to create a SPARQL query that will retrive only the external identifiers for a record. Basically, I want to retrieve the items listed under the "Identifers" section on one of the dedicated pages, e.g. https://www.wikidata.org/wiki/Q112133367 includes the IMDB movie ID and the Rotten Tomatoes ID for the film.
I am able to get all the available properties for an item (I know the item's Wikidata ID). This is something like SELECT * FROM wikidata WHERE id='Q112133367'
:
SELECT ?value ?valueLabel ?prop ?propLabel {
wd:Q112133367 ?prop ?value .
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
}
I've tried using the VALUES
syntax, which I think is equivalent in this case (?):
SELECT ?item ?value ?valueLabel ?prop ?propLabel ?p2 ?p2Label {
VALUES (?item) {(wd:Q112133367)}
?item ?prop ?value .
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
}
But so far I have been unable to limit the properties returned to only ones that are External Identifiers. This is what I tried, but this results in "No matching records found":
SELECT ?item ?value ?valueLabel ?prop ?propLabel ?p2 ?p2Label {
VALUES (?item) {(wd:Q112133367)}
?item ?prop ?value .
?prop wikibase:propertyType wikibase:ExternalId .
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
}