Help:SPARQL query examples: Difference between revisions

From DataTrek
Jump to navigation Jump to search
mNo edit summary
No edit summary
Line 1: Line 1:
<languages /><translate><!--T:1-->
Questa pagina conterrà esempi dettagliati per usare lo endpoint SPARQL.
Questa pagina conterrà esempi dettagliati per usare lo endpoint SPARQL.


<!--T:2-->
Si tratta di una caratteristica '''sperimentale'''.
Si tratta di una caratteristica '''sperimentale'''.


<!--T:3-->
== Dove si trova ==
== Dove si trova ==
https://wdqs.wikitrek.org
https://wdqs.wikitrek.org


<!--T:4-->
== Cosa serve ==
== Cosa serve ==
https://en.wikipedia.org/wiki/SPARQL
https://en.wikipedia.org/wiki/SPARQL


<!--T:5-->
== Esempi da Wikidata ==
== Esempi da Wikidata ==
https://www.wikidata.org/wiki/Wikidata:SPARQL_tutorial
<div class="mw-heading mw-heading2">
  <h2>Queries with cats</h2>
</div>
<div class="mw-heading mw-heading3">
  <h3>Cats</h3>
</div>
<syntaxhighlight lang="sparql">
SELECT ?cat ?catLabel WHERE {
  ?cat prefix:P1 prefix:Q2
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en". }
}
</syntaxhighlight>


<!--T:6-->
<div class="mw-heading mw-heading2">
== Esempi ==
  <h2>Queries with dogs</h2>
{{Help:SPARQL_query_examples/queries}}
</div>
</translate>
<div class="mw-heading mw-heading3">
  <h3>Dogs</h3>
</div>
<syntaxhighlight lang="sparql">
SELECT ?dog ?dogLabel WHERE {
  ?dog prefix:P1 prefix:Q3
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en". }
}
</syntaxhighlight>
 
 
<!-- === Episodi di Lower Decks === -->
__NOTOC__
<div class="mw-heading mw-heading3">
  <h3>Episodi di Lower Decks</h3>
</div>
Elenco di episodi di '''''[[wikitrek:Star Trek: Lower Decks|Lower Decks]]'''''
<syntaxhighlight lang="sparql" line>
PREFIX wd: <https://data.wikitrek.org/entity/>
PREFIX wdt: <https://data.wikitrek.org/prop/direct/>
SELECT ?episode ?episodeLabel ?publication ?production WHERE {
  ?episode wdt:P14 wd:Q10317;
          wdt:P101 ?publication;
          wdt:P1 ?production
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]". }
  }
ORDER BY ASC (?production)
</syntaxhighlight>
 
=== Episodi di Prodigy ===
Elenco di episodi di '''''[[wikitrek:Star Trek: Prodigy|Prodigy]]'''''
<syntaxhighlight lang="sparql">
PREFIX wd: <https://data.wikitrek.org/entity/>
PREFIX wdt: <https://data.wikitrek.org/prop/direct/>
SELECT ?episode ?episodeLabel ?publication ?production WHERE {
  ?episode wdt:P14 wd:Q10692;
          wdt:P101 ?publication;
          wdt:P1 ?production
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]". }
  }
ORDER BY ASC (?production)
</syntaxhighlight>
 
=== Planets ===
A list of planets.
<pre>
SELECT ?planet WHERE {
  ?planet wdt:P31 wd:Q634.
}
</pre>
 
=== Starships ===
Starships in the galaxy.
<pre>
SELECT ?starship WHERE {
  ?starship wdt:P31 wd:Q170383.
}
</pre>

Revision as of 23:06, 9 January 2025

Questa pagina conterrà esempi dettagliati per usare lo endpoint SPARQL.

Si tratta di una caratteristica sperimentale.

Dove si trova

https://wdqs.wikitrek.org

Cosa serve

https://en.wikipedia.org/wiki/SPARQL

Esempi da Wikidata

Queries with cats

Cats

SELECT ?cat ?catLabel WHERE {
  ?cat prefix:P1 prefix:Q2
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en". }
}

Queries with dogs

Dogs

SELECT ?dog ?dogLabel WHERE {
  ?dog prefix:P1 prefix:Q3
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en". }
}


Episodi di Lower Decks

Elenco di episodi di Lower Decks

PREFIX wd: <https://data.wikitrek.org/entity/>
PREFIX wdt: <https://data.wikitrek.org/prop/direct/>
	
SELECT ?episode ?episodeLabel ?publication ?production WHERE {
  ?episode wdt:P14 wd:Q10317;
           wdt:P101 ?publication;
           wdt:P1 ?production
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]". }
  }
ORDER BY ASC (?production)

Episodi di Prodigy

Elenco di episodi di Prodigy

PREFIX wd: <https://data.wikitrek.org/entity/>
PREFIX wdt: <https://data.wikitrek.org/prop/direct/>
	
SELECT ?episode ?episodeLabel ?publication ?production WHERE {
  ?episode wdt:P14 wd:Q10692;
           wdt:P101 ?publication;
           wdt:P1 ?production
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]". }
  }
ORDER BY ASC (?production)

Planets

A list of planets.

SELECT ?planet WHERE {
  ?planet wdt:P31 wd:Q634.
}

Starships

Starships in the galaxy.

SELECT ?starship WHERE {
  ?starship wdt:P31 wd:Q170383.
}