0
votes

I Have a node called Member it has Relationships to Clubs and Shops I want to create a query so that I can return Member with Clubs and Shops

MATCH (m: Member { username: $memberUsername ,
                  password: $password})<- [r: MEMBER_BELONGS_TO_CLUBS] - (c: Club)
RETURN m, c, r

in the example I get Member and Clubs but I want to get member Clubs and member Shops

1
So what is Shop and why it is not included in your query? - Lazar Đorđević

1 Answers

0
votes

If your node M is connected like this S -> M <- C (M is Member, S is Shop, and C is Club), then you can use query similar like example in 4.2 Multiple Relationships in documentation:

MATCH (s: Shop) - [rs: MEMBER_BELONGS_TO_SHOPS] ->
      (m: Member { username: $memberUsername ,
                   password: $password}) <- [r: MEMBER_BELONGS_TO_CLUBS] - (c: Club)
RETURN m, c, r, s, rs

Also you can use syntax like in this example with multiple MATCH:

MATCH (m: Member { username: $memberUsername ,
                  password: $password})
MATCH (s: Shop) - [rs: MEMBER_BELONGS_TO_SHOPS] -> (m)
MATCH (m) <- [r: MEMBER_BELONGS_TO_CLUBS] - (c: Club)
RETURN m, c, r, s, rs

And both queries returns something only if M is connected with both S and C. If you don't want that restrictions you can use OPTIONAL MATCH documentation.