User:SilentSpike/SPARQL
Personal SPARQL Reference Page edit
Motivation for this was that I find the example queries from the query service to be too descriptive and specific. They don't let me easily find the syntax I need to accomplish a certain task.
Items with P1 with qualifier P2=Q1 edit
SELECT DISTINCT ?item WHERE {
?item p:P1 [ pq:P2 ?qualValue ].
FILTER (?qualValue = wd:Q1)
}
LIMIT 100
Items with P1 without qualifier P2 edit
SELECT DISTINCT ?item WHERE {
?item p:P1 ?prop.
FILTER(NOT EXISTS { ?prop pq:P2 _:x. })
}
LIMIT 100
Items with P1 with string value containing "substring" edit
SELECT DISTINCT ?item ?v where {
?item wdt:P1 ?v.
FILTER (contains(?v, "substring"))
}
LIMIT 100
Statements qualified with P1 edit
SELECT DISTINCT ?statement where {
?statement pq:P1 _:x.
}
LIMIT 100
Compare usage of qualifier P1 with values Q1 and Q2 edit
select * {
{
select (count(distinct ?s) AS ?count_1) {
?s pq:1 wd:Q1.
}
}
{
select (count(distinct ?s) AS ?count_2) {
?s pq:1 wd:Q2.
}
}
}
Items with P1 with value Q1 or Q2 edit
SELECT DISTINCT ?item WHERE
{
VALUES ?vals {wd:Q1 wd:Q2}
?item wdt:P1 ?vals.
}