query-b0ccf26325f238993deb96e3c4de0ab0

rq turtle/ttl

Useful SPARQL queriesConverting "instance of", table for importing into QuickStatements:

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 
(REPLACE(STR(?item), ".*/", "") AS ?qid) 
("Q1311696" AS ?_P31)
("Q336764" AS ?P31)
WHERE {
  ?item wdt:P31 wd:Q1311696.
  SERVICE wikibase:label {
    bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,ru,zh,de,fr".
    ?item rdfs:label ?label.
  }
  BIND(LCASE(?label) AS ?llabel)
}
ORDER BY ((CONTAINS(?llabel, "junction"))|| (CONTAINS(?llabel, "railway")))

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v6("?P31") v5("?_P31") v2("?item"):::projected v3("?label") v4("?llabel") v4("?qid") c4(["wd:Q1311696"]):::iri c6(["bd:serviceParam"]):::iri c8(["#91;AUTO_LANGUAGE#93;,en,ru,zh,de,fr"]):::literal v2 --"wdt:P31"--> c4 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c6 --"wikibase:language"--> c8 v2 --"rdfs:label"--> v3 end bind0[/"lower-case(?label)"/] v3 --o bind0 bind0 --as--o v4 bind1[/"replace(str(?item),'.*/','')"/] v2 --o bind1 bind1 --as--o v4 bind2[/"'Q1311696'"/] bind2 --as--o v5 bind3[/"'Q336764'"/] bind3 --as--o v6