query-3c9ef4effbdc58fda85589ff8912200f
SPARQL query shows deleted item The following query: Sometimes I need to rethink my logic for SPARQL to give the right result that don't start with UC and aren't 24 characters long (a correct YouTube channel id starts with UC and is 24 characters long). I wrote a query and it seemed to work: (P2397)YouTube channel ID For a tool I created I needed to return all the items (+current value and GUID for statement) with the value for
Use at
- https://query.wikidata.org/sparql
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX p: <http://www.wikidata.org/prop/>
SELECT ?item ?YouTube ?YouTubeEntity WHERE {
?item wdt:P2397 ?YouTube .
?item p:P2397 ?YouTubeEntity .
filter(SUBSTR(str(?YouTube),1,2)!="UC")
}
Query found at
- https://www.wikidata.org/wiki/Wikidata:Contact_the_development_team/Archive/2016/01
- https://www.wikidata.org/wiki/Wikidata_talk:SPARQL_query_service/queries/Archive/2016
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v1("?YouTube"):::projected
v3("?YouTubeEntity"):::projected
v2("?item"):::projected
f0[["substring(str(?YouTube),'1^^xsd:integer','2^^xsd:integer') != 'UC'"]]
f0 --> v1
v2 --"p:direct/P2397"--> v1
v2 --"p:P2397"--> v3