I'm new to SPARQL and I'm trying to fetch some results from triples in a SQL join fashion.
e.g. I'm looking for the ID of the object a certain image belongs to, and the ID of the author of the object, and so on.
RDF relations are defined like this:
<image> <isResourceOf> <object>
<person> <isAuthorOf> <object>
I tried this:
SELECT ?o ?a from <#ri>
WHERE {
{<myns:myImageID> <myns:isResourceOf> ?o}
UNION
{?a <myns:isAuthorOf> ?o}
}
But this fetches all the authors, since the two ?o
variables are not bound.
How do I get to match the authors ONLY for the first match set?
Thanks
gm
EDIT:
More complete example:
PREFIX aic: <http://mydomain.org/definitions/1.0/fedora/3#>
SELECT *
WHERE {
<info:fedora/AICTEST:DOResImg-G38562> aic:isResourceOf ?o .
?a aic:isAuthorOf ?o .
}
No results.
SELECT *
WHERE {
<info:fedora/AICTEST:DOResImg-G38562> aic:isResourceOf ?o .
}
Results (CSV):
"o"
AICTEST:DOArtObj-1946.479
With this:
SELECT *
WHERE {
?a aic:isAuthorOf ?o .
}
Results:
"a","o"
info:fedora/AICTEST:DOAgent-35729,info:fedora/AICTEST:DOArtObj-1946.479
info:fedora/AICTEST:DOAgent-35729,AICTEST:DOObjSet-1946.494