I have the following SPARQL query that returns the items related to Q42.
 To avoid the compute time of making an additional query I would like to
tweak this query to return one additional row that contains the
information about Q42 itself using the same columns.  Is there a special
property that indicates a self relationship, or any other way of
accomplishing the above in one query?

      PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
      PREFIX wikibase: <http://wikiba.se/ontology#>
      PREFIX entity: <http://www.wikidata.org/entity/>
      PREFIX p: <http://www.wikidata.org/prop/direct/>

      SELECT ?propUrl ?propLabel ?valUrl ?valLabel ?picture
      WHERE {
        hint:Query hint:optimizer 'None' .
        entity:Q42 ?propUrl ?valUrl .
        ?valUrl rdfs:label ?valLabel

        FILTER (LANG(?valLabel) = 'en') .

        ?property ?ref ?propUrl .
        ?property a wikibase:Property .
        ?property rdfs:label ?propLabel

        OPTIONAL{
          ?valUrl p:P18 ?picture .
        }
        FILTER (lang(?propLabel) = 'en' )
       }
      ORDER BY ?propUrl ?valUrl LIMIT 200


Please advise,
James Weaver

_______________________________________________
Wikidata mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikidata

Reply via email to