On 13/10/17 02:36, Dimov, Stefan wrote:
Hello,
I have two graphs:
Which storage system are they in?
Which version of Jena?
m_p
p1 pred1 mp1
p2 pred1 mp1
p3 pred1 mp2
p4 pred1 mp2
p5 pred1 mp3
p6 pred1 mp3
and m_p_s
mp1 pred2 w:frnd
mp1 pred2 w:fdlfkdl
mp2 pred2 w:kdsjflk
mp2 pred2 w:jflksdlkj
mp3 pred2 w:frnd
mp3 pred2 w:fjksldjfls
Please could you provide complete data such as TriG?
It is a barrier to volunteers who answers questions if the first thing
you have to do is mangle email, data preparation and disentangle partial
queries.
and I want to get all the triples in m_p which objects are predicates in m_p_s
and the object of that predicates in m_p_s is w:frnd
In other words I want to make query that returns (results with) p1, p2, p5 and
p6 from m_p and doesn’t return p3 and p4.
I’m trying to do this with nested queries,
You don't need a nested SELECT.
SELECT * {
GRAPH m_p { ?s ?p ?o }
GRAPH m_p_s { ?x ?o w:frnd }
}
(untested)
but it doesn’t work: E.g.
SELECT $subj $pred $pr
$subj and $pred are not set in the query.
This isn't SQL! In SPARQL, variables get bound in graph patterns.
FROM NAMED named_graph:m_p
The RDF dataset for this query is a single named graph and empty default
graph.
Did you mean:
FROM NAMED named_graph:m_p
FROM NAMED named_graph:m_p_s
?
or indeed no FROM NAMED and use a dataset directly.
WHERE
{
SELECT $pr
WHERE
{
GRAPH named_graph:m_p_s { $pr $pred0 w:frnd }
the m_p_s graph isn't in the dataset hence this pattern is empty.
GRAPH is for access; FROM NAMED for setting up.
}
}
returns empty result. I tried different things, but either I get an error
What is the error?
or empty result or everything in m_p.
I don’t want to use UNION or FILTER for performance reasons.
Do you have an idea how I can do it?
Regards,
Stefan