query-5048313b66dba46a4862b4885709ebe5

rq turtle/ttl

and not, you can use an OPTIONAL clause e.g. like this: (Q1233)Sandro Pertini . To get results both named after LuckyzHi 11:32, 18 April 2020 (UTC)) talk (Andrew Gray). You'll have to do a little manual cleanup to pick only the relevant items, but it should be reasonably easy. aliases (named in the (Q528184)Turin Airport ) or description (where Pertini is mentioned in the (Q1239022)Carla Voltolina The problem is that it can't search in labels only, so you also get things like should do it. It finds anything matching "Sandro Pertini" in the label/alias/description fields, and removes anything known (from SPARQL) to be named after him.This query: You can do this through PetScan - one of the options there is the "normal" Wikidata search. Dipsacus fullonum, Luckyz@ did the job. In the meantime, I don't understand what's wrong with my query:Andrew GrayThanks both, I think

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 ?itemDescription ?named_afterLabel  WHERE {
      SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }

  ?item wdt:P31 wd:Q126807.
  ?item rdfs:label ?label.
  FILTER CONTAINS(?label, "Sandro Pertini")
  OPTIONAL
  {
    ?item wdt:P138 wd:Q1233.
    VALUES ?named_after_Q1233 { true }
  }
  OPTIONAL { ?item  wdt:P138 ?named_after  } 

  SERVICE wikibase:label { bd:serviceParam wikibase:language "it,[AUTO_LANGUAGE],en" .
                           ?named_after rdfs:label ?named_afterLabel . 

                  }
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v2("?item"):::projected v1("?label") v4("?named_after") v5("?named_afterLabel"):::projected v3("?named_after_Q1233") c11(["it,#91;AUTO_LANGUAGE#93;,en"]):::literal c3(["bd:serviceParam"]):::iri c5(["en"]):::literal c7(["wd:Q126807"]):::iri c10(["wd:Q1233"]):::iri f0[["contains(?label,'Sandro Pertini')"]] f0 --> v1 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c3 --"wikibase:language"--> c5 end v2 --"wdt:P31"--> c7 v2 --"rdfs:label"--> v1 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v2 -."wdt:P138".-> c10 bind1[/VALUES ?named_after_Q1233/] bind1-->v3 bind10(["true^^xsd:boolean"]) bind10 --> bind1 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v2 -."wdt:P138".-> v4 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c3 --"wikibase:language"--> c11 v4 --"rdfs:label"--> v5 end