Hi Team,
In neo4j I have created 2 parent nodes as A and B. The value of A and B will be like this.
A={databaseA:"tracker",name:"SAM"} B={databaseB:"consumer",name:"Stark"}
Now Dynamically I am creating some child node with relationship with A and B. As a Happy path I have created with both combination A and B
<>
MATCH (a:Table1)
WHERE a.databaseA="tracker"
MATCH (b:Table2)
WHERE b.databaseB="consumer"
CREATE (d: Consumer{name:"abc", age:24})
MERGE (d)<-[:REL_WITH_A]-(a)
MERGE (d)<-[:REL_WITH_B]-(b)
RETURN d
</>
Now node will be create and relationship will be created from A and B.
My Goal is to create a single query If the above statement fails it need to check the with the condition a.databaseA="tracker"
in case it is true need to create the child node with A relationship only
CREATE (d: Consumer{name:"abc", age:24}) MERGE (d)<-[:REL_WITH_A]-(a)
Same rule will be applicable for B.