Project:SPARQL/examples
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],mul,en". } # Helps get the label in your language, if not, then en (English) language
}
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],mul,en". } # Helps get the label in your language, if not, then en (English) language
}
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],mul,en". } # Helps get the label in your language, if not, then en (English) language
}
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],mul,en". } # Helps get the label in your language, if not, then en (English) language
}