Project:SPARQL/examples: Difference between revisions

From MetaBase
Jump to navigation Jump to search
No edit summary
No edit summary
Line 5: Line 5:
PREFIX wbt: <https://metabase.wikibase.cloud/prop/direct/>
PREFIX wbt: <https://metabase.wikibase.cloud/prop/direct/>


SELECT ?item ?itemLabel ?same_wikidata ?wikidata_iri ?url ?twitter ?instagram
SELECT ?item ?itemLabel ?wikidata_iri ?url ?twitter ?instagram
WHERE
WHERE
{
{
?item wbt:P5 wb:Q13 .
?item wbt:P5 wb:Q13 .
?item wbt:P1 ?same_wikidata.
?item wbt:P1 ?wikidataQ.


BIND(URI(concat("http://www.wikidata.org/entity/",?same_wikidata)) AS ?wikidata_iri)
BIND(URI(concat("http://www.wikidata.org/entity/", ?wikidataQ)) AS ?wikidata_iri)


SERVICE <https://query.wikidata.org/sparql> {
SERVICE <https://query.wikidata.org/sparql> {

Revision as of 14:42, 24 April 2023

Federated queries

Organizations and their social media and official website (from Wikidata)

PREFIX wb: <https://metabase.wikibase.cloud/entity/>
PREFIX wbt: <https://metabase.wikibase.cloud/prop/direct/>

SELECT ?item ?itemLabel ?wikidata_iri ?url ?twitter ?instagram
WHERE
{
?item wbt:P5 wb:Q13 .
?item wbt:P1 ?wikidataQ.

BIND(URI(concat("http://www.wikidata.org/entity/", ?wikidataQ)) AS ?wikidata_iri)

SERVICE <https://query.wikidata.org/sparql> {
 OPTIONAL {?wikidata_iri wdt:P856 ?url.}
 OPTIONAL {?wikidata_iri wdt:P2002 ?twitter.}
 OPTIONAL {?wikidata_iri wdt:P2003 ?instagram.}
}

SERVICE wikibase:label { bd:serviceParam wikibase:language "sv,en". }
}

Try it!