query-8d9e2b2c1c201b0a7b9972977bd08798

rq turtle/ttl

title:Anime/manga characters with anidb character link or prefilled search query SELECT ?item ?anidb WHERE { { ?item wdt:P31 wd:Q80447738. } UNION { ?item wdt:P31 wd:Q87576284. } UNION { ?item wdt:P5648 ?__anidb. }

OPTIONAL { ?item wdt:P5648 ?_anidb. }

?item rdfs:label ?itemLabel. FILTER (lang(?itemLabel) = 'en')

BIND( IF(!BOUND(?_anidb), CONCAT("https://anidb.net/character/?do.search=1&adb.search=",ENCODE_FOR_URI(?itemLabel)), CONCAT("https://anidb.net/character/",?_anidb) ) AS ?anidb) }

Use at

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#>
#title:Anime/manga characters with anidb character link or prefilled search query
SELECT ?item ?anidb WHERE {
  { ?item wdt:P31 wd:Q80447738. }
  UNION
  { ?item wdt:P31 wd:Q87576284. }
  UNION
  { ?item wdt:P5648 ?__anidb. }

  OPTIONAL { ?item wdt:P5648 ?_anidb. }

  ?item rdfs:label ?itemLabel.
  FILTER (lang(?itemLabel) = 'en')

  BIND(
    IF(!BOUND(?_anidb),
       CONCAT("https://anidb.net/character/?do.search=1&adb.search=",ENCODE_FOR_URI(?itemLabel)),
       CONCAT("https://anidb.net/character/",?_anidb)
    )
  AS ?anidb)
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v3("?__anidb") v4("?_anidb") v5("?anidb"):::projected v2("?item"):::projected v1("?itemLabel") c4(["wd:Q87576284"]):::iri c3(["wd:Q80447738"]):::iri f0[["?itemLabel = 'en'"]] f0 --> v1 subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; subgraph union1[" Union "] subgraph union1l[" "] style union1l fill:#abf,stroke-dasharray: 3 3; v2 --"wdt:P5648"--> v3 end subgraph union1r[" "] style union1r fill:#abf,stroke-dasharray: 3 3; v2 --"wdt:P31"--> c4 end union1r <== or ==> union1l end end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v2 --"wdt:P31"--> c3 end union0r <== or ==> union0l end subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v2 -."wdt:P5648".-> v4 end v2 --"rdfs:label"--> v1 bind1[/"if(not bound(?_anidb),concat('https://anidb.net/character/?do.search=1&adb.search=',encode-for-uri(?itemLabel)),concat('https://anidb.net/character/',?_anidb))"/] v4 --o bind1 v1 --o bind1 bind1 --as--o v5