A typical SPARQL query that specifies a graph might look like this:
SELECT ?b ?c WHERE { GRAPH <http://AliceIRI> {
<http://local.virt/foo> ?b ?c}}
This will tell me all the triples in AliceIRI where "foo" is a subject. What if I want to look in two different graphs, is my only option to do a UNION:
SELECT ?b ?c WHERE {{ GRAPH <http://AliceIRI> {
<http://local.virt/foo> ?b ?c}}
UNION
{ GRAPH <http://BobIRI> {
<http://local.virt/foo> ?b ?c}}}
Or is there some shorthand that would allow me to write this more conveniently, something like this:
SELECT ?b ?c WHERE { GRAPH <http://AliceIRI> + <http://BobIRI> {
<http://local.virt/foo> ?b ?c}
BTW I'm on Virtuoso 6.01.3127.
Update 1
To clarify, I'd really like to be able to run:
SELECT ?b ?c WHERE { GRAPH <http://AliceIRI> + <http://BobIRI> {
<http://local.virt/foo> ?b ?c .
<http://local.virt/bar> ?b ?c}}
and have this match ?b
and ?c
such that <http://local.virt/foo> ?b ?c
is in <http://AliceIRI>
and <http://local.virt/bar> ?b ?c
is in <http://BobIRI>
. Simply taking the union of matches in <http://AliceIRI>
(alone) and <http://BobIRI>
(alone) won't accomplish this.
And to clarify further: I've realized that if the foos all belonged to Alice and the bars all belonged to Bob, then I could write
SELECT ?b ?c WHERE {
GRAPH <http://AliceIRI> {
<http://local.virt/foo> ?b ?c } .
GRAPH <http://BobIRI> {
<http://local.virt/bar> ?b ?c}}
(which is actually what I needed for my application) -- but at least for "academic interest" the question of whether there is a syntactically nice way to run a query against a union of graphs (as opposed to against multiple graphs and then union the results) still stands.