Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
02-06-2021 09:10 AM
I have the following Graph where Nodes can be connected like this :
I Need to write a query so that I get either A or B as an output.
Thanks in advance for the help.
02-06-2021 09:28 AM
Not sure what you really want, we would need more information about your domain ( what's the labels, properties of your nodes etc. ) to better fits your need.
But here is a general answer for your case:
MATCH (n1)-[:COPY_OF]->(n2)
RETURN n1
Since it's a really basic query I would highly suggest to read a lot more about Cypher.
There is a basic course.
You can enroll on each part of this course by clicking one of the 5 parts with the proposed order.
02-06-2021 09:32 AM
HI @tard.gabriel ,
Thanks a lot for your reply.
The query that you are proposing will return both A and B.
I want to either A or B as an output and not both.
02-06-2021 09:35 AM
TO Add more to the use cases. Here is the scenario :
I have n master questions.
When I create a Survey I have two options I can create a fresh question or can create a copy of these master questions.
Now, Suppose if the user creates two questions with the same master question.
I don't want the responder to see both questions(as they are a copy) I want them to see either 1.
Hopefully this helps.
02-06-2021 09:40 AM
As there is not enough information about your model ( like @karora7190 said ) to chose one of them based on any criteria you can do this as a general answer:
MATCH (n1)-[:COPY_OF]->(n2)
RETURN n1 LIMIT 1
A empty model get an empty answer, give a soul or context to your question.
A graph and questions related to it is useless without a soul or context.
All the sessions of the conference are now available online