问题
I couldn't find a similar post, so if you already know one or if my question is not the proper one, please let me know.
I have this query
MATCH
(t:Taxi {name:'Taxi1813'})<-[:ASSIGNED]-(u2:User)-[rd2:DROP_OFF]->
(g2:Grid)-[r:TO*1..2]-(g:Grid)<-[rd:DROP_OFF]-(u:User)-[:ASSIGNED]->(t)
WHERE ID(u2) < ID(u) AND rd2.time >= '04:38' AND rd2.time <= '04:42'
WITH DISTINCT u2, g2, u, g, rd2, rd
MATCH p=shortestPath((g2)-[r:TO*1..2]-(g))
WITH rd2, rd,u2, g2, u, g, p, REDUCE(totalTime = 0, x IN RELATIONSHIPS(p) | totalTime + x.time) AS totalTime
WHERE totalTime <= 4
RETURN u2.name, u.name
So at the end i got two columns
u2.name u.name
User179 UserTest
User177 User179
Is there is a way or function to merge both columns into a single one and remove duplicates
Users
User179
User177
UserTest
Any suggestions? Thank you
回答1:
You can combine the two collections into a single collection and then return just the distinct items.
with ['User179', 'User177'] as list1
, ['UserTest', 'User179'] as list2
unwind list1 + list2 as item
return distinct item
回答2:
u2.name + u.name combines the list
you could make something like "where u2.name is not equal to u.name(not right syntax)"
来源:https://stackoverflow.com/questions/34659152/cyhper-combine-two-columns-into-a-single