Wikidata:WikiProject Anime and Manga/Queries

From Wikidata
Jump to navigation Jump to search

List of interesting queries.

Characters[edit]

Get all anime/manga characters[edit]

#title:Get all anime/manga characters
SELECT ?item ?itemLabel WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  {
    SELECT DISTINCT ?item WHERE {
      { ?item wdt:P31 wd:Q80447738. }
      UNION
      { ?item wdt:P31 wd:Q87576284. }
      UNION
      { ?item wdt:P5648 ?__anidb. }
      UNION
      { ?item wdt:P4085 ?__mal. }
    }
  }
}
Get all anime/manga characters

Anime/manga characters with anidb character link or prefilled search[edit]

#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)
}
Anime/manga characters with anidb character link or prefilled search query

Other[edit]

Ranma 1/2 chapters[edit]

#title:Ranma 1/2 chapters
SELECT ?item ?itemLabel ?ord
(GROUP_CONCAT(DISTINCT ?episodeLabel; separator=", ") AS ?episodes)
(GROUP_CONCAT(DISTINCT ?characterLabel; separator=", ") AS ?characters)
WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  ?item wdt:P31 wd:Q53460949.
  ?item wdt:P179 wd:Q272015.
  OPTIONAL {
    ?item p:P179 [ pq:P1545 ?ord ].
    ?episode wdt:P144 ?item.
    ?episode rdfs:label ?episodeLabel.
    FILTER ( LANGMATCHES ( LANG ( ?episodeLabel ), "en" ) ) 
  }
  OPTIONAL {
    ?item wdt:P674 ?character.
    ?character rdfs:label ?characterLabel.
    FILTER ( LANGMATCHES ( LANG ( ?characterLabel ), "en" ) ) 
    
  }
} GROUP BY ?item ?itemLabel ?ord
Ranma 1/2 chapters

Manga not classifed as series or one-shot[edit]

#title:Manga not classified as series or one-shot
SELECT ?item ?itemLabel WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  ?item wdt:P31 wd:Q8274.
  MINUS { ?item wdt:P31 wd:Q21198342 }
  MINUS { ?item wdt:P31 wd:Q21202185 }
}
Manga not classified as series or one-shot

Manga with the same ID as another manga[edit]

#title: manga items with the same IDQ11381433
SELECT DISTINCT ?manga1 ?manga2 WHERE {
  ?manga1 wdt:P31/wdt:P279* wd:Q8274.
  ?prop wdt:P31 wd:Q101083593.
  ?prop wikibase:directClaim ?propClaim.
  ?manga1 ?propClaim ?id.
  ?manga2 ?propClaim ?id.
  FILTER (?manga1 != ?manga2).
  FILTER NOT EXISTS {?manga1 ?x ?manga2}
}
manga items with the same IDQ11381433

Manga without a japanese name[edit]

#title: manga without a japanese name, ordered by sitelinks
SELECT ?manga ?sitelinks {
  ?manga wdt:P31/wdt:P279* wd:Q8274.
  FILTER NOT EXISTS {
    ?manga rdfs:label ?label.
    FILTER(LANG(?label) = "ja").
  }
  ?manga wikibase:sitelinks ?sitelinks
}
manga without a japanese name, ordered by sitelinks

Anime that is both a tv show and a movie[edit]

#title: anime that is both a series and a movie
SELECT ?item ?itemLabel ?sl WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  ?item wdt:P31 wd:Q20650540.
  ?item wdt:P31 wd:Q63952888.
  ?item wikibase:sitelinks ?sl.
} ORDER BY DESC(?sl)
anime that is both a series and a movie