Dear Kamal and Michale,
thank you both very much for your replies. I went for Michale's solution as 
it looked a bit more synthetic. It worked with minor adjustments. Here is 
how it looks like:

MATCH (a:LabelA) where CONDITION-a WITH collect(a) as nodes1
MATCH (b:LabelB) where CONDITION-b WITH collect(b) + nodes1 as nodes2
MATCH (c:LabelC) where CONDITION-c WITH collect(c) + nodes2 as nodes3
UNWIND nodes3 as n
MATCH (n)-[rel:X|Y|Z]->(m)
WHERE n IN nodes3 AND m in nodes3
RETURN n, rel, m 

If I did not use several variables (node1, node2, etc) but jest "nodes" 
Cypher gave me this error (not sure why): 

Unexpected error during late semantic checking: Variable `  nodes@142` not 
defined

And I had to add a condition also to the m nodes as they too needed to be 
among those previously selected. Otherwise the query looks pretty good, 
thank you again to both for the suggestion!

Cheers,
Simone.


Il giorno giovedì 4 maggio 2017 21:27:22 UTC+2, Michael Hunger ha scritto:
>
> MATCH (a:A {a:"a"}) WITH collect(a) as nodes
> MATCH (b:B {b:"b"}) WITH collect(b) + nodes as nodes
> MATCH (c:C {c:"c"}) WITH collect(c) + nodes as nodes
> UNWIND nodes as n
> MATCH (n)-[rel:X|Y|Z]->(m)
> WHERE n IN nodes
> RETURN n, rel, m
>
>
> On Thu, May 4, 2017 at 7:33 PM, Kamal Murthy <[email protected] 
> <javascript:>> wrote:
>
>> Hi Simone,
>>
>>
>> Here is the query that worked for me:
>>
>>
>> MATCH (c)-[]->(n)-[]->(p:Cusine)
>> WHERE p.name = "Mexican"
>> WITH DISTINCT n
>>
>> MATCH (c)-[]->(n1)-[]->(p:Features)
>> WHERE n1.id = n.id and p.price = "medium"
>> WITH DISTINCT n1
>>
>> MATCH PATH = (c)-[]-(n1)-[r:FEATURES|CUISINE]->(n3)
>> RETURN PATH;
>>
>> -Kamal
>>
>>
>> On Thursday, May 4, 2017 at 1:14:57 AM UTC-7, Simone Z wrote:
>>>
>>> Dear All,
>>> I am a novice in Cypher and I would greatly appreciate some help with a 
>>> query.
>>>
>>> In my database I have several nodes labels (A, B, C...) and relationship 
>>> types (X, Y , Z).
>>>
>>> I would like to get a subset of the database, where nodes A respect 
>>> condition a, nodes B condition b and nodes C condition c, and get any edge 
>>> of type X, Y or Z connecting any selected node.
>>>
>>> How would the query look like?
>>>
>>> Thank you!
>>>
>>>
>>>
>>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Neo4j" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to