thanx very much Brian! I figured it out. If you could tell me whether it is possible to get COUNT also. I mean, in one query with SELECT something. It doesnt need to be this query, just imaginary query, SELECT something, and get the count. I want to use it in conjunction with LIMIT. LIMIT to 10 for instance and get the remaining COUNT (those that were not selected).
Would like to help, I am thankful. Jan 2011/10/20 Brian McBride <[email protected]> > So your query is: > > [[ > > > SELECT ?name ?title > { > ?s dc:title ?title. > ?o foaf:name ?name. > ?o foaf:name "Donald D. Chamberlin" > } > LIMIT 5 > > ]] > > That doesn't do what you think it does, because it does relate ?o to ?s. ?o > can be anything with a foaf:name property of "Donald D. Chamberlin" and > ?name will return all the values for the foaf:name property for that > resource - there is only one - "Donald D. Chamberlin". > > What you need to do is get a query that will return the other authors of > the publication, e.g. > > SELECT ?coauthorName ?title > WHERE { > ?author foaf:name "Donald D. Chamberlin" . # put first as its most > restrictive > ?publication <editor> ?author . # now select all the publications with that > author as editor > # you didn't provide a namespace for the editor property > ?title dc:title ?title # get the title of the publication > ?publication <editor> ?coauthor . # now find all the authors of that > publication > FILTER (?coauthor != ?author) # eliminate the original author specified > ?coauthor foaf:name ?coauthorName # get the name of the coauthor > > # done > > } > > On 20/10/2011 11:41, Ján Mojžiš wrote: > >> Hi there, >> I have a following-type records: >> >> <rdf:Description >> rdf:about="http://www.w3.org/**TR/xquery <http://www.w3.org/TR/xquery> >> "><dc:identifier>www/**org/w3/TR/xquery</dc:** >> identifier><dc:date>2002-01-**03</dc:date><rdf:type >> rdf:resource="http://sw.deri.**org/~aharth/2004/07/dblp/dblp.**owl#Www<http://sw.deri.org/%7Eaharth/2004/07/dblp/dblp.owl#Www> >> "/> >> <editor><foaf:Person rdf:nodeID="DonaldDChamberlin"**><foaf:name>Donald >> D. >> Chamberlin</foaf:name></foaf:**Person></editor> >> <editor><foaf:Person rdf:nodeID="DanielaFlorescu"><**foaf:name>Daniela >> Florescu</foaf:name></foaf:**Person></editor> >> <editor><foaf:Person rdf:nodeID="JonathanRobie"><**foaf:name>Jonathan >> Robie</foaf:name></foaf:**Person></editor> >> <editor><foaf:Person >> rdf:nodeID="Jérô**meSiméon"><foaf:name>J&#**xE9;rôme >> Siméon</foaf:name></foaf:**Person></editor> >> <editor><foaf:Person rdf:nodeID="MugurStefanescu"><**foaf:name>Mugur >> Stefanescu</foaf:name></foaf:**Person></editor> >> <dc:title rdf:parseType="Literal">**XQuery: A Query Language for >> XML</dc:title> >> <year>2001</year> >> >> They are books or publications, where each one can have multiple authors >> (co-authors). >> >> First I search books based on foaf:person - one author. To get his >> publications. My working query is: >> >> PREFIX foaf:<http://xmlns.com/foaf/0.**1/ <http://xmlns.com/foaf/0.1/>> >> PREFIX >> rdf:<http://www.w3.org/1999/**02/22-rdf-syntax-ns#<http://www.w3.org/1999/02/22-rdf-syntax-ns#>> >> #type >> PREFIX >> dc:<http://purl.org/dc/**elements/1.1/<http://purl.org/dc/elements/1.1/>> >> # identifier, date, >> creator, title >> SELECT ?name ?title >> { >> ?s dc:title ?title. >> ?o foaf:name ?name. >> ?o foaf:name "Donald D. Chamberlin" >> } >> LIMIT 5 >> >> It returns >> ------------------------------**------------------------------** >> ------------------------------**------------ >> | name | >> title >> ==============================**==============================** >> ==============================**============ >> | "Donald D. Chamberlin" | "PRPL: A Database Workload Specification >> Language, v1.3."^^rdf:XMLLiteral >> | "Donald D. Chamberlin" | "Efficient View Maintenance at Data >> Warehouses."^^rdf:XMLLiteral >> | "Donald D. Chamberlin" | "Self-organizing >> Map"^^rdf:XMLLiteral >> | "Donald D. Chamberlin" | "Beowulf Project at >> CESDIS"^^rdf:XMLLiteral >> | "Donald D. Chamberlin" | "The MPEG Home >> Page"^^rdf:XMLLiteral >> ------------------------------**------------------------------** >> ------------------------------**------------ >> >> But also I want co-authors of each found match! NOW how to get co-authors? >> I >> have spent many hours trying to get co-authors in single query, with no >> success. >> Please be so kind to help. >> >> Many thanks >> Jan >> >>
