user000111181
user000111181

Reputation: 423

Add a relationship Neo4j based upon a condition

I have 2 node Labels : Account , Transactions.

MATCH (n:Account)
RETURN n

returns me 4 accounts with this property's:

accountName RAHUL RAINA
id  16294736
accountName SAVINGS ACCOUNT - RES
id  16294732
accountName VISA GOLD
id  16294492
accountName SBCHQ-GEN-PUB-IND-NONRURAL-INR
id  16294488

Transactions is like this :

MATCH (n:Transaction) 
RETURN n LIMIT 5

and this returns me :

id  133817384
description ATM07JUN15 NFS 11:38:44A96103218ATM
postedDate  6/8/2015
transactionDate 6/8/2015
accountId   16294732
id  133815940
description TO TRANSFER INB Tinyowl Technology Privat
postedDate  6/8/2015
transactionDate 6/8/2015
accountId   16294488

I want to make a link between these two node labels or a relationship (I am not sure what it is called ) when the transaction.accountId == account.id

How do I do this.

Upvotes: 1

Views: 47

Answers (1)

Nicole White
Nicole White

Reputation: 7790

MATCH (a:Account), (t:Transaction)
WHERE a.id = t.accountId
CREATE (t)-[:FROM_ACCOUNT]->(a)

Upvotes: 2

Related Questions