cyhper将两列合并为一个 [英] cyhper combine two columns into a single
本文介绍了cyhper将两列合并为一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我找不到类似的帖子,因此,如果您已经知道一个帖子,或者如果我的问题不正确,请告诉我.
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.
我有这个查询
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
所以最后我有两列
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
有什么建议吗?谢谢
推荐答案
您可以将两个集合合并为一个集合,然后仅返回不同的项目.
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
或者,如果您使用的是APOC,则可以使用apoc.coll.union()
.
Alternatively, if you are using APOC you could use apoc.coll.union()
instead.
WITH ['User179', 'User177'] AS list1
, ['UserTest', 'User179'] AS list2
RETURN apoc.coll.union(list1,list2)
这篇关于cyhper将两列合并为一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文