Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 如何查询具有特定属性的相邻顶点?_Sql_Graph_Orientdb - Fatal编程技术网

Sql 如何查询具有特定属性的相邻顶点?

Sql 如何查询具有特定属性的相邻顶点?,sql,graph,orientdb,Sql,Graph,Orientdb,我正在使用OrientDB 2.0。这个问题很简单,但我似乎想不出来。我有两个类:User和UserGroup。简单来说,User只有username和password属性,而UserGroup只有一个id属性。关系很简单: User--用户组-->用户组 其中,user\u group是一类连接user和UserGroup顶点的边 我想做的是获得一个具有特定用户名和密码的用户,其中UserGroup.id等于group1 到目前为止,我得到的是: select expand(in('user_

我正在使用OrientDB 2.0。这个问题很简单,但我似乎想不出来。我有两个类:
User
UserGroup
。简单来说,
User
只有
username
password
属性,而UserGroup只有一个
id
属性。关系很简单:

User--用户组-->用户组

其中,
user\u group
是一类连接
user
UserGroup
顶点的边

我想做的是获得一个具有特定用户名和密码的用户,其中
UserGroup.id
等于group1

到目前为止,我得到的是:

select expand(in('user_group')[username='foo' and password='bar']) 
from UserGroup
where id = 'group1'

但这对我不起作用。我做错了什么?

我想,经过几次尝试,我找到了答案:

select from 
   (select expand(in('user_group'))
    from UserGroup
    where id = 'group1')
where username='foo' and password='bar'
如果有人能提出一个更优雅的解决方案,那也太好了

select 
from (
     select expand(in('user_group')) 
     from UserGroup 
     where id = 'group1'
) 
where username='foo' and password='bar'
create class User extends V
create property User.username string
create property User.password string

create class UserGroup extends V
create property UserGroup.id string

create class user_group extends E


create vertex User set username = 'foo', password = 'bar'
create vertex UserGroup set id = 'group1'

create edge user_group from (select from User where username = 'foo') to (select from UserGroup where id = 'group1')


select expand(in('user_group')[username='foo'][password='bar']) 
from UserGroup
where id = 'group1'