如何实现两个表的连接

例如我有两个表格,我想要用以下格式将其连接起来,请问这个需要怎么做呢
表格1

userID msgID
10 20
11 21
12 21
13 22

表格2

msgID count
20 4
21 5

连接结果

userID msgID count
10 20 4
11 21 5
12 21 5
13 22 0

用mysql就可以做到
如果你需要用图来描述,可以考虑下nebula

表1和表2都是我用nebula 的ngql yield后得到的结果,就是想问怎么用ngql连接两个结果

如果msgID和count是仅有的两个属性的话,那么作为tag加给对应的点,然后fetch prop on * vertexID也可以。
这个需求用yield挺合适的

1 个赞

表格1和2是已经yield之后的结果,只是两个暂存的变量,请问该怎么做才能得到表格3

可以先查询出表一 然后使用管道符查询表二 在合并

前两个表格我是这样得到的,请问我该怎么利用管道获得两个表的合并结果呢?

$a = yield xxx.userID as userID, xxx.msgID as msgID;\
$b = yield yyy.msgID as msgID, yyy.count as count

那一条语句也能查出来,先查出来符合的userID,再通过管道符传给后面的查询,最后yield userid、msgid、count就行

请问意思是这样吗?

 yield xxx.userID as userID, xxx.msgID as msgID | fetch prop on yyy $-.msgID | yield $-.userID, $-.msgID, $-.count 

但是这样管道的最后一部分就无法识别userID了,显示column not exist

同样,下面两句也无法运行,请问可以给一个能work的方法吗

 yield xxx.userID as userID, xxx.msgID as msgID | fetch prop on yyy $-.msgID | yield $xxx.userID, $-.msgID, $-.count;

 yield xxx.userID as userID, xxx.msgID as msgID | fetch prop on yyy $-.msgID | yield xxx.userID, $-.msgID, $-.count;

下面这个语句则是显示 SyntaxError: $-' and $variable’ not supported in fetch yet.

 yield xxx.userID as userID, xxx.msgID as msgID | fetch prop on yyy $-.msgID yield yyy.msgID, yyy.count, $-.userID 

跟楼主交流过以后发现两个query的确不太能联合起来 :sweat_smile:
本来是ldbc的一个例子
查了下用cypher会比较好表达