Project:SPARQL/examples: Difference between revisions

From lgbtDB
Jump to navigation Jump to search
(Created page with "This page is parsed by the web interface of the [https://lgbtdb.wikibase.cloud/query/ query service] to fill the query example dialog. For general examples and their explanations, please see here. == Simple Queries == === Instances === ==== Instances of gender identities ==== This query returns all instances of gender identities in lgbtDB. It uses the service wikibase:label to return the labels in your default language or in English. <sparql...")
 
No edit summary
Line 13: Line 13:
{
{
   ?item wdt:P1 wd:Q10639 . # Must be a gender identity
   ?item wdt:P1 wd:Q10639 . # Must be a gender identity
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en". } # Helps get the label in your language, if not, then en (English) language
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } # Helps get the label in your language, if not, then en (English) language
}
}
</sparql>
</sparql>
Line 27: Line 27:
{
{
   ?item wdt:P1 wd:Q226 . # Must be a romantic orientation
   ?item wdt:P1 wd:Q226 . # Must be a romantic orientation
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en". } # Helps get the label in your language, if not, then en (English) language
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } # Helps get the label in your language, if not, then en (English) language
}
}
</sparql>
</sparql>
Line 41: Line 41:
{
{
   ?item wdt:P1 wd:Q10638 . # Must be a sexual orientation
   ?item wdt:P1 wd:Q10638 . # Must be a sexual orientation
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en". } # Helps get the label in your language, if not, then en (English) language
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } # Helps get the label in your language, if not, then en (English) language
}
}
</sparql>
</sparql>
Line 55: Line 55:
{
{
   ?item wdt:P1 wd:Q179 . # Must be a website
   ?item wdt:P1 wd:Q179 . # Must be a website
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en". } # Helps get the label in your language, if not, then en (English) language
   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } # Helps get the label in your language, if not, then en (English) language
}
}
</sparql>
</sparql>
Line 62: Line 62:


=== Dates ===
=== Dates ===
==== Instances of real-life people with a birth or death date available ====
This query returns all instances of real-life (human) persons with a birth or death date available. It uses the service wikibase:label to return the labels in your default language or in English.
PREFIX wd: <https://lgbtdb.wikibase.cloud/entity/>
PREFIX wdt: <https://lgbtdb.wikibase.cloud/prop/direct/>
<sparql tryit="1">PREFIX wd: <https://lgbtdb.wikibase.cloud/entity/>
PREFIX wdt: <https://lgbtdb.wikibase.cloud/prop/direct/>
SELECT DISTINCT ?item ?itemLabel ?bdate ?ddate
WHERE
{
  ?item wdt:P1 wd:Q8775 . # Must be a human person (a real-life person)
  ?item wdt:P141|wdt:P142 [] . # Must have a birthdate or deathdate available
  OPTIONAL { ?item wdt:P141 ?bdate . } # Date of birth
  OPTIONAL { ?item wdt:P142 ?ddate . } # Date of death
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } # Helps get the label in your language, if not, then en (English) language
}
</sparql>


=== Lexemes ===
=== Lexemes ===


[[Category:Query Service]]
[[Category:Query Service]]

Revision as of 15:10, 24 August 2024

This page is parsed by the web interface of the query service to fill the query example dialog. For general examples and their explanations, please see here.

Simple Queries

Instances

Instances of gender identities

This query returns all instances of gender identities in lgbtDB. It uses the service wikibase:label to return the labels in your default language or in English.

PREFIX wd: <https://lgbtdb.wikibase.cloud/entity/>
PREFIX wdt: <https://lgbtdb.wikibase.cloud/prop/direct/>

SELECT ?item ?itemLabel
WHERE
{
  ?item wdt:P1 wd:Q10639 . # Must be a gender identity
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } # Helps get the label in your language, if not, then en (English) language
}

Try it!


Instances of romantic orientations

This query returns all instances of romantic orientations in lgbtDB. It uses the service wikibase:label to return the labels in your default language or in English.

PREFIX wd: <https://lgbtdb.wikibase.cloud/entity/>
PREFIX wdt: <https://lgbtdb.wikibase.cloud/prop/direct/>

SELECT ?item ?itemLabel
WHERE
{
  ?item wdt:P1 wd:Q226 . # Must be a romantic orientation
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } # Helps get the label in your language, if not, then en (English) language
}

Try it!


Instances of sexual orientations

This query returns all instances of sexual orientations in lgbtDB. It uses the service wikibase:label to return the labels in your default language or in English.

PREFIX wd: <https://lgbtdb.wikibase.cloud/entity/>
PREFIX wdt: <https://lgbtdb.wikibase.cloud/prop/direct/>

SELECT ?item ?itemLabel
WHERE
{
  ?item wdt:P1 wd:Q10638 . # Must be a sexual orientation
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } # Helps get the label in your language, if not, then en (English) language
}

Try it!


Instances of websites

This query returns all instances of websites in lgbtDB. It uses the service wikibase:label to return the labels in your default language or in English.

PREFIX wd: <https://lgbtdb.wikibase.cloud/entity/>
PREFIX wdt: <https://lgbtdb.wikibase.cloud/prop/direct/>

SELECT ?item ?itemLabel
WHERE
{
  ?item wdt:P1 wd:Q179 . # Must be a website
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } # Helps get the label in your language, if not, then en (English) language
}

Try it!


Subclasses

Dates

Instances of real-life people with a birth or death date available

This query returns all instances of real-life (human) persons with a birth or death date available. It uses the service wikibase:label to return the labels in your default language or in English.

PREFIX wd: <https://lgbtdb.wikibase.cloud/entity/> PREFIX wdt: <https://lgbtdb.wikibase.cloud/prop/direct/>

PREFIX wd: <https://lgbtdb.wikibase.cloud/entity/>
PREFIX wdt: <https://lgbtdb.wikibase.cloud/prop/direct/>

SELECT DISTINCT ?item ?itemLabel ?bdate ?ddate
WHERE 
{
  ?item wdt:P1 wd:Q8775 . # Must be a human person (a real-life person)
  ?item wdt:P141|wdt:P142 [] . # Must have a birthdate or deathdate available
  OPTIONAL { ?item wdt:P141 ?bdate . } # Date of birth
  OPTIONAL { ?item wdt:P142 ?ddate . } # Date of death
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } # Helps get the label in your language, if not, then en (English) language
}

Try it!


Lexemes