Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You can't do this, I'm afraid. The results of a <code>SELECT</code> (or, in fact, any <code>WHERE</code>) are tabular, and you can't have nested tables (as found in some relational databases) or any other suitable structure.</p> <p>The straightforward option is add an <code>ORDER BY ?item</code> to your existing query. That will keep everything together at least, so you can process item by item. In the past I've written wrappers to iterate over relational data like this, allowing something like:</p> <pre><code>foreach (item: iterateOverBy(results, "item") foreach (date: iterateOverBy(results, "date") foreach (title: iterateOverBy(results, "title") foreach (info: iterateOverBy(results, "info") ...do something... </code></pre> <p>But SPARQL can return RDF, of course, so you could use:</p> <pre><code>CONSTRUCT { ?item dct:date ?date ; dct:title ?title ; rdfs:info ?info } WHERE ... </code></pre> <p>Internally that will do the same work, but the result won't contain lots of repetition like the <code>SELECT</code> will.</p> <p>My final suggestion isn't appropriate to the problem as given, but I ought to mention it.</p> <p>So far the actual query processing hasn't really changed, just the form of the results. But suppose the query where of the form:</p> <pre><code>WHERE { ...some condition to select items... ?item dct:date ?date . ?item ... as before ... } </code></pre> <p>The condition might be <code>FILTER (?date &gt; ...something...)</code> or <code>?item rdf:type ex:InterestingItem</code>, or whatever.</p> <p>In this case you might consider <code>DESCRIBE</code>:</p> <pre><code>DESCRIBE ?item WHERE { ...some condition to select items... } </code></pre> <p>That will return (in rdf) information about the items that match that condition. Here the query just picks out the items, not the things we want to know about them.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload