query-5c91a23e66e0e57dff73473a3302c815

rq turtle/ttl

People by surname and initial 12:32, 5 March 2023 (UTC) Andy's edits; Talk to Andy); Pigsonthewing (Andy MabbettI need to find out if we have an item about, for example, a person called "E.W. Badger". Could we have a query for people with the surname "Badger" and a first name beginning with "E", please? This should work

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
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#>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?item ?itemLabel WHERE {
  ?item wdt:P31 wd:Q5 .
  ?item wdt:P734  wd:Q16479693  . # Family name Badger
  ?item wdt:P735 ?name .
  ?name rdfs:label ?nameLabel .
  FILTER (LANG(?nameLabel) = "en")
  FILTER (STRSTARTS(?nameLabel, "E"))
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v2("?item"):::projected v3("?name") v1("?nameLabel") c10(["bd:serviceParam"]):::iri c4(["wd:Q5"]):::iri c12(["#91;AUTO_LANGUAGE#93;,en"]):::literal c6(["wd:Q16479693"]):::iri f0[["starts-with(?nameLabel,'E')"]] f0 --> v1 f1[["?nameLabel = 'en'"]] f1 --> v1 v2 --"wdt:P31"--> c4 v2 --"wdt:P734"--> c6 v2 --"wdt:P735"--> v3 v3 --"rdfs:label"--> v1 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c10 --"wikibase:language"--> c12 end