Project:SPARQL/examples

From lgbtDB
Revision as of 15:10, 24 August 2024 by Superraptor (talk | contribs)
Jump to navigation Jump to search

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