Re: [Tracker] A quick question



Hi,

On Wed, 2010-02-24 at 10:22 +0800, Zheng, Huan wrote:
Hi, how can I select all music files that has no performer?

 

What I do now is use the following select and check the result, if the
second value is blank, then that song has no performer,

Track-sparql âq âSELECT ?song ?performer WHERE { OPTIONAL { ?song
nmm:performer ?performer} } GROUP by (?performer)â

Is there a better way?

tracker-sparql -q 'SELECT ?song WHERE {
        ?song a nmm:MusicPiece .
        OPTIONAL { ?song nmm:performer ?performer }
        FILTER (!BOUND(?performer))
}'

This returns all songs where nmm:performer has no value.

Say SELECT ?song WHERE {!{?song nmm:performer ?performer}} ?

Unfortunately, it's not possible in such a short form in SPARQL 1.0.
However, with SPARQL 1.1 (currently a draftÂ) the following is possible:

SELECT ?song WHERE {
        ?song a nmm:MusicPiece .
        NOT EXISTS { ?song nmm:performer ?performer }
}

This is not yet implemented in Tracker.

Regards,
JÃrg

 http://www.w3.org/TR/sparql11-query/#negation





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]