cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

I need to combine those 2 queries please and do not get duplicated values

match (n:HealthcareServiceRequest) where n.AuthorizationNumber in ['2208390000']

and n.AuthRequestType = '005010X217' and n.EventName = 'Response278'

Match (m:Attachments275) where n.AttachControlNumber = m.AttachmentControlNumber

return m.Attachmentpath, n.AuthorizationNumber order by n.EventCreationDateTime desc

match (n:HealthcareServiceRequest) where n.AuthorizationNumber in ['2208390000']

and n.AuthRequestType = '005010X217' and n.EventName = 'Response278'

return n.TransactionID, n.AuthorizationNumber order by n.EventCreationDateTime desc

10 REPLIES 10

The second query is searching for the same HealthcareServiceRequest entity as the first query, but the return items are not the same. Adding the transactId to return statement of the first query doesn’t get you what you want?

Is it the case that there is not always a Attachments275 entity in the first query, so you don’t get results? If so, switch the match on the attachment275 to an optional match.

I am sorry i didnt get it
How should the query will be
I did some research and get that one
match (n:HealthcareServiceRequest) where n.AuthorizationNumber in %s

and n.AuthRequestType = '005010X217' and n.EventName = 'Response278'

Match (m:Attachments275) where n.AttachControlNumber = m.AttachmentControlNumber

return n.AuthorizationNumber as Authorization_ID, n.TransactionID as TransactionID, m.Attachmentpath as Attachmentpath order by n.EventCreationDateTime desc

Is that correct ???

What about the query does not work?

I was suggesting the following to address the situation where there is not an associated attachment, but you still want a result.


match (n:HealthcareServiceRequest) where n.AuthorizationNumber in %s
and n.AuthRequestType = '005010X217' and n.EventName = 'Response278'

Optional Match (m:Attachments275) where n.AttachControlNumber = m.AttachmentControlNumber

return n.AuthorizationNumber as Authorization_ID, n.TransactionID as TransactionID, m.Attachmentpath as Attachmentpath order by n.EventCreationDateTime desc

When i run the query I executed i got duplicated results like that pic

And i need to get only one record not multiple

You must have multiple Attachment275 nodes that meet the requirement.

Change the query's return to below, so we can see if there are multiple Attachment275 nodes:

return id(n), id(m)

What do you get?

Can you give me the full query you want me to try it please ?

I am sorry i didn't work on it before

sure:

match (n:HealthcareServiceRequest) where n.AuthorizationNumber in ['2207090003']
and n.AuthRequestType = '005010X217' and n.EventName = 'Response278'
Match (m:Attachments275) where n.AttachControlNumber = m.AttachmentControlNumber

return id(n), id(m)

I am getting this result

Just what I thought. You have multiple Attachment275 nodes that meet the requirement. The results look like duplicates because the fields you are returning for the Attachment275 nodes have the same values. In reality, they are different nodes. id(m) is the internal neo4j id for the Attachment275 nodes returned. The values are all different, thus they are different nodes.

Do you expect this, or have these nodes been unintentionally duplicated? Are all the properties for these nodes identical?

Run this query if you want to compare the Attachment275 nodes:

match (n:HealthcareServiceRequest) where n.AuthorizationNumber in ['2207090003']
and n.AuthRequestType = '005010X217' and n.EventName = 'Response278'
Match (m:Attachments275) where n.AttachControlNumber = m.AttachmentControlNumber

return id(n), id(m), properties(m)