I am using the following SPARQL query from PHP where $title
is the same for all five query triples:
SELECT * WHERE {
{ <http://dbpedia.org/resource/$title> rdfs:label ?pageTitle . }
UNION
{ <http://dbpedia.org/resource/$title> owl:sameAs ?sameAs . }
UNION
{ <http://dbpedia.org/resource/$title> dbpedia-owl:abstract ?abstract . }
UNION
{ <http://dbpedia.org/resource/$title> dbpedia-owl:thumbnail ?thumbnail . }
UNION
{ <http://dbpedia.org/resource/$title> dbpedia-owl:wikiPageID ?wikiID . }
}
Is there a way to simplify this so that $title
is only specified once in the query? I am thinking an anonymous node might be involved, somewhere? perhaps? :-)
SELECT * WHERE {
<http://dbpedia.org/resource/$title> ?p ?o .
FILTER (?p IN (rdfs:label, owl:sameAs, dbpedia-owl:abstract, dbpedia-owl:thumbnail, dbpedia-owl:wikiPageID))
Instead of FILTER (?x IN ())
you can also use VALUES (?x) {<...>, <...> }
as mentioned in another reply