Hello,

I have two graphs:

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

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, but it doesn’t work: E.g.

    SELECT $subj $pred $pr
                FROM NAMED named_graph:m_p
                WHERE
    {
        SELECT $pr
        WHERE
        {
           GRAPH named_graph:m_p_s { $pr $pred0 w:frnd }
        }
    }

returns empty result. I tried different things, but either I get an 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

Reply via email to