orientdb sql查询以选择边和顶点字段属性。
我有以下数据库结构 用户->评论->产品 a。用户和产品是包含一些信息等的顶点:用户名、产品名和。。。。 B注释是包含注释和创建/修改日期的边 为了显示以下结果,sql查询可能是什么样子的 注意:我必须展示所有可能有或没有评论的产品orientdb sql查询以选择边和顶点字段属性。,sql,orientdb,graph-databases,Sql,Orientdb,Graph Databases,我有以下数据库结构 用户->评论->产品 a。用户和产品是包含一些信息等的顶点:用户名、产品名和。。。。 B注释是包含注释和创建/修改日期的边 为了显示以下结果,sql查询可能是什么样子的 注意:我必须展示所有可能有或没有评论的产品 产品名称、用户名、注释、注释创建日期、注释修改日期 产品名称、用户名称、''''''''' 产品名称、用户名、注释、注释创建日期、注释修改日期 如果以上是您的情况,我相信您正在寻找的查询类似于: select *, expand(inE('Comment')) fr
select *, expand(inE('Comment')) from Product
更新:
这不是很漂亮,但作为一种解决方法,您可以使用:
select *, inE('Comment').include('comment', 'createDate', 'modifiedDate') from Product
查询时不能“联接”类/表。相反,将结果集->从Product
s的边缘类开始,与Comment
s合并,然后使用let
和unionall()
在expand()之前添加非Comment
edProduct
s:
select expand($c)
let $a = (select in.name as name, out.name as User, comment, createDate, modifiedDate from Comment),
$b = (select from Product where in_Comment is null),
$c = unionall($a, $b)
请注意,在结果集中,第一次查询(即$a
结果集)中的@CLASS
字段为null
s,第二次查询($b
结果集)中的字段为字段,使用@vitorenesduarte模式,以下查询可能符合当前要求
select name AS product_name,in(comment).name
AS user_name,inE(comment).comment
AS comment,inE(comment).createDate
AS comment_created_date,inE(comment).modifiedDate
AS comment_modified_date from product
OP要求所有产品,以及没有评论(边缘)的产品。另外请注意,这个问题的关键是同时具有注释边缘(如果存在)和产品的属性。根据给定的查询,它只显示与注释边缘相关的结果。这不是我的本意。我期待着得到的结果,显示评论边缘和产品在每一行。嗨@martin。你说得对,我刚测试过。但它应该起作用。我正在查询所有字段和一些RID的扩展。我不知道扩展函数的行为是这样的。我曾尝试用变量来解决它,但没有成功。试着问问,也许有人能帮你。嗨,马丁。我已经开始谈论这件事了。问题解决后,你可以采纳我的建议。同时,我找不到任何解决办法:(让我们看看只选择没有任何评论的产品的$b。有评论的产品怎么样?它们被$a抓住了
select name AS product_name,in(comment).name
AS user_name,inE(comment).comment
AS comment,inE(comment).createDate
AS comment_created_date,inE(comment).modifiedDate
AS comment_modified_date from product