Christian, > I don't think that is correct. Even the SPARQL spec has the following example (6.1): > SELECT ?name ?mbox > WHERE { ?x foaf:name ?name . > OPTIONAL { ?x foaf:mbox ?mbox } > }
> If ?x would be taken from within the optional clause only, the name and email address would not need to match at all. You're right. If a variable is use multiple times in different patterns then either 'natural' or 'left outer' join is made, except UNION of course. Nevertheless FILTERing takes place before that joins and it does not pay attention to variables outside the local group pattern. You may treat above query like SELECT ?name ?mbox WHERE { ?x foaf:name ?name . OPTIONAL { ?xinner foaf:mbox ?mbox } FILTER (?x = ?xinner) . } Best Regards, Ivan Mikhailov. -----Original Message----- From: Christian Weiske [mailto:cwei...@cweiske.de] Sent: Tuesday, August 07, 2007 22:12 To: Ivan Mikhailov; virtuoso-users@lists.sourceforge.net Subject: Re: [Virtuoso-users] virtuoso + iodbc Ivan, > Consider the first OPTIONAL with a FILTER: > OPTIONAL { ?publ <http://test/#publicationAuthor> ?p2. > ?p2 <http://test/#emailAddress> ?p2mail. > FILTER(?p1 != ?p2) } > > Unlike SQL, all used ?p1 bindings will be taken solely from the > OPTIONAL {...} clause. There are no bindings of ?p1 in that clause at > all so the FILTER condition should get same value regardless ?p1 > binding outside the clause. This is probably not what you need. I don't think that is correct. Even the SPARQL spec has the following example (6.1): SELECT ?name ?mbox WHERE { ?x foaf:name ?name . OPTIONAL { ?x foaf:mbox ?mbox } } If ?x would be taken from within the optional clause only, the name and email address would not need to match at all. -- Regards/Mit freundlichen Grüßen Christian Weiske