简体   繁体   English

如何在orientdb中将数据从一个类获取到另一个

[英]how to fetch data from one class to another in orientdb

I have created two classes customer and city . 我创建了customercity两个类。 customer class contain two properties name and location and city class contain id and location . 客户类别包含名称位置两个属性, 城市类别包含id位置 I want to perform join operations on these two classes. 我想对这两个类执行联接操作。 I create a graph relation in orientdb studio and fire a query below 我在orientdb Studio中创建一个图形关系,并在下面触发查询

select from customer where city.location='pune'

but this query not returning any value,it executed but not returning any field, So, this is correct syntax or i am doing wrong in somewhere .. please give me solutions. 但是此查询不返回任何值,它执行但不返回任何字段,所以,这是正确的语法,或者我在某处做错了..请给我解决方案。

I have this simple dataset to give you some examples: 我有这个简单的数据集给你一些例子:

create class Customer extends V
create class City extends V
create class livesAt extends E

create property Customer.name String
create property City.id integer
create property City.location String

create vertex Customer set name="Tom"
create vertex Customer set name="John"
create vertex City set id=1, location="London"
create vertex City set id=2, location="Pune"

create edge livesAt from (select from Customer where name="Tom") to (select from City where id=1)
create edge livesAt from (select from Customer where name="John") to (select from City where id=2)

Now you can use different queries to retrieve the results you're looking for. 现在,您可以使用不同的查询来检索所需的结果。


Query 1a : Starting from Customer (like your query above) 查询1a :从客户开始(如上面的查询)

select from Customer where out('livesAt').location in 'Pune'

Output : 输出

----+-----+--------+----+-----------
#   |@RID |@CLASS  |name|out_livesAt
----+-----+--------+----+-----------
0   |#12:1|Customer|John|[size=1]
----+-----+--------+----+-----------

Query 1b : Starting again from Customer 查询1b :从客户再次开始

select from Customer where out('livesAt').location contains 'Pune'

Output : 输出

----+-----+--------+----+-----------
#   |@RID |@CLASS  |name|out_livesAt
----+-----+--------+----+-----------
0   |#12:1|Customer|John|[size=1]
----+-----+--------+----+-----------

Query 1c : 查询1c

select from Customer where out('livesAt')[location = 'Pune'].size() > 0

Output : 输出

----+-----+--------+----+-----------
#   |@RID |@CLASS  |name|out_livesAt
----+-----+--------+----+-----------
0   |#12:1|Customer|John|[size=1]
----+-----+--------+----+-----------

Query 2 : Starting from City ( more direct ) 查询2 :从城市开始( 更直接

select expand(in('livesAt')) from City where location = 'Pune'

Output : 输出

----+-----+--------+----+-----------
#   |@RID |@CLASS  |name|out_livesAt
----+-----+--------+----+-----------
0   |#12:1|Customer|John|[size=1]
----+-----+--------+----+-----------

Hope it helps 希望能帮助到你

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM