How to retrieve multiple depth relationships NEO4J DATABASE CYPHER?

Suppose there is a simple chart as follows,

(City {name:gotham})<-[:LOCATED] -(Tower {name:abc})<-[:LOCATED]-(Bank:{name:CityBank})
(City {name:gotham})<-[:LOCATED]-(Cinema {name:MainHall })
(City {name:gotham})<-[:LOCATED]-(Bank {name:ComBank})

How can I find it in the Neo4j database (including CityBank and comBank) All the banks named Gotham? I tried the following pattern, and it returned all nodes located in City, named gotham (including Cinema)

MATCH (City(name:'Gotham'))<-- (Bank) RETURN Bank

Assuming you entered the query incorrectly, what doesn’t work?

MATCH (:City(name:'Gotham'))<--(bank:Bank) RETURN bank

It should work fine.

Completely wrong typing, should read (lone star indication, all relations of any type, path of any length):

MATCH (:City{ name:'Gotham'})<-[*]-(bank:Bank) RETURN bank

Better is:

MATCH (:City {name:'Gotham'})<-[:LOCATED*1..2]-(bank:Bank) RETURN bank

So it can only traverse the LOCATED relationship. You can adjust* 1..2( Match paths with a length of 1 to 2) to meet the path length requirement (for example, if you add a street or block node, you may need to match a path with a length of 3*1. )

Suppose there is a simple chart as follows,

(City {name:gotham})<-[:LOCATED]-(Tower {name:abc} )<-[:LOCATED]-(Bank:{name:CityBank})
(City {name:gotham})<-[:LOCATED]-(Cinema {name:MainHall})
(City {name:gotham})<-[:LOCATED]-(Bank {name:ComBank})

How can I find all banks named Gotham in the Neo4j database (including CityBank and comBank)? I tried the following pattern, and it returned all nodes located in City, named gotham (including Cinema)

MATCH (City(name:'Gotham'))<-- (Bank) RETURN Bank

Assuming you entered the query incorrectly, what does it not work?

MATCH (:City(name:'Gotham'))<--(bank:Bank) RETURN bank

It should work fine.

Completely wrong typing, should read (lone star indication, all relations of any type, path of any length):

MATCH (:City{ name:'Gotham'})<-[*]-(bank:Bank) RETURN bank

Better is:

MATCH (:City {name:'Gotham'})<-[:LOCATED*1..2]-(bank:Bank) RETURN bank

So it can only traverse the LOCATED relationship. You can adjust* 1..2( Match paths with length 1 to 2) to meet the path length requirement (for example, if you add a street or block node, you may need to match a path with a length of 3 * 1. )

< /p>

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 2742 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.