I would like to get the provincial or territorial capital city in Canada with the names of the provinces.
SELECT ?item ?itemLabel ?provinceOrTerritoryLabel
WHERE
{
?item wdt:P31 wd:Q21507383. # provincial or territorial capital city in Canada (Q21507383)
wd:Q21507383 pq:P642 ?provinceOrTerritory.
?provinceOrTerritory wdt:P31 wd:Q11828004. # province of Canada (Q11828004)
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
I thought that this should work but it is not the case.
Thank you very much for your help!
EDIT
My intention here is really to understand how to get a lot of wikidata that are related with the property "of (P642)". For instance, for Toronto (https://www.wikidata.org/wiki/Q172), we get:
instance of > provincial or territorial capital city in Canada > of (P642) > Ontario