title: run a sparql query against two graphs?
body: <p>A typical SPARQL query that specifies a graph might look like this:</p>
  
  <pre><code>SELECT ?b ?c WHERE { GRAPH &lt;http://AliceIRI&gt; {
  &lt;http://local.virt/foo&gt; ?b ?c}}
  </code></pre>
  
  <p>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:</p>
  
  <pre><code>SELECT ?b ?c WHERE {{ GRAPH &lt;http://AliceIRI&gt; {
  &lt;http://local.virt/foo&gt; ?b ?c}}
  UNION
  { GRAPH &lt;http://BobIRI&gt; {
  &lt;http://local.virt/foo&gt; ?b ?c}}}
  </code></pre>
  
  <p>Or is there some shorthand that would allow me to write this more conveniently, something like this:</p>
  
  <pre><code>SELECT ?b ?c WHERE { GRAPH &lt;http://AliceIRI&gt; + &lt;http://BobIRI&gt; {
  &lt;http://local.virt/foo&gt; ?b ?c}
  </code></pre>
  
  <p>BTW I'm on Virtuoso 6.01.3127.</p>
  
  <p><strong>Update 1</strong> </p>
  
  <p>To clarify, I'd really like to be able to run:</p>
  
  <pre><code>SELECT ?b ?c WHERE { GRAPH &lt;http://AliceIRI&gt; + &lt;http://BobIRI&gt; {
  &lt;http://local.virt/foo&gt; ?b ?c .
  &lt;http://local.virt/bar&gt; ?b ?c}}
  </code></pre>
  
  <p>and have this match <code>?b</code> and <code>?c</code> such that <code>&lt;http://local.virt/foo&gt; ?b ?c</code> is in <code>&lt;http://AliceIRI&gt;</code> and <code>&lt;http://local.virt/bar&gt; ?b ?c</code> is in <code>&lt;http://BobIRI&gt;</code>.  Simply taking the union of matches in <code>&lt;http://AliceIRI&gt;</code> (alone) and <code>&lt;http://BobIRI&gt;</code> (alone) won't accomplish this.</p>
  
  <p>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</p>
  
  <pre><code>SELECT ?b ?c WHERE { 
  GRAPH &lt;http://AliceIRI&gt; {
  &lt;http://local.virt/foo&gt; ?b ?c } .
  GRAPH &lt;http://BobIRI&gt; {
  &lt;http://local.virt/bar&gt; ?b ?c}}
  </code></pre>
  
  <p>(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.</p>