query-063ba7702b4c2c7322cb0275369c8fba
Query for last name
Use at
- https://query.wikidata.org/sparql
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT *
WHERE
{
{
SELECT ?item ?name ?l
{
BIND( wd:Q42 as ?item)
?item rdfs:label ?l .
FILTER( lang(?l) = "en" )
# BIND(strafter(?l, " ") as ?name)
BIND(REPLACE(?l, "^.+ (.+)$", "$1") as ?name)
}
}
OPTIONAL { ?lastname wdt:P31 wd:Q101352 ; rdfs:label ?name }
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v2("?item"):::projected
v1("?l"):::projected
v4("?lastname"):::projected
v3("?name"):::projected
c4(["wd:Q101352"]):::iri
f0[["?l = 'en'"]]
f0 --> v1
bind1[/"'wd:Q42'"/]
bind1 --as--o v2
v2 --"rdfs:label"--> v1
bind2[/"replace(?l,'^.+ (.+)$','$1')"/]
v1 --o bind2
bind2 --as--o v3
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v4 -."wdt:P31".-> c4
v4 --"rdfs:label"--> v3
end