Thank you David! In hindsight, using the full URI makes perfect sense.
Sincerely,
Michael


On Fri, Mar 10, 2023 at 12:33 AM Fichtmüller, David <D.Fichtmueller@bo.berlin> wrote:
Hey Michael,
when querying Wikidata, you need to use the item's concept URI and not just its Q-number. The following query will bring you the result you want:
All the best
  David

PREFIX ira:<https://ir-authorities.wikibase.cloud/entity/>
PREFIX irp:<https://ir-authorities.wikibase.cloud/prop/direct/>
PREFIX wdt:<http://www.wikidata.org/prop/direct/>

SELECT ?person ?wikidataQNumber ?country
WHERE {
   ?person irp:P20 ira:Q174;         # is a human
           irp:P2 ?wikidataQNumber.  # wikidata identifier
   BIND(URI(CONCAT("http://www.wikidata.org/entity/", ?wikidataQNumber)) AS ?wikidataURI).
   OPTIONAL {
     SERVICE <https://query.wikidata.org/sparql> {
           ?wikidataURI wdt:P27 ?country.
     }
   }
}

-----Ursprüngliche Nachricht-----
Von: Michael Lindsey <mlindsey@berkeley.edu>
Gesendet: Mittwoch, 8. März 2023 18:21
An: wikibaseug@lists.wikimedia.org
Betreff: [Wikibase] outbound SERVICE to Wikidata?

Hi all,
I don't see my Monday post in the list archives, so I can't amend it.
I am attempting to bring a wikidata property, if present, into query results on my wikibase.cloud instance, but am getting nothing.
I have managed to create what I think is the simplest code to demonstrate my problem.
The below query ( https://tinyurl.com/2f8wzeoj ) executes without error.
Am I missing something, or can we not use Wikidata as a SERVICE?
Thanks for any insight you may have!
Michael Lindsey
UC Berkeley School of Law

PREFIX ira:<https://ir-authorities.wikibase.cloud/entity/>
PREFIX irp:<https://ir-authorities.wikibase.cloud/prop/direct/>
PREFIX wdt:<http://www.wikidata.org/prop/direct/>

SELECT ?person ?wikidataQNumber ?country WHERE {
   ?person irp:P20 ira:Q174;                  # is a human
                  irp:P2 ?wikidataQNumber.  # wikidata identifier
   OPTIONAL {
     SERVICE <https://query.wikidata.org/sparql> {
           ?wikidataQNumber wdt:P27 ?country.
     }
   }
}
_______________________________________________
Wikibase Community User Group mailing list -- wikibaseug@lists.wikimedia.org To unsubscribe send an email to wikibaseug-leave@lists.wikimedia.org