Hi John,

You have a few alternatives here:

the easiest one:

SELECT unionAll($a, $b)
LET
$a = (SELECT expand(out("provides")) FROM Employee WHERE name =
:employeeName),
$b = (SELECT expand(out("belongs_to").out("provides")) FROM Employee WHERE
name = :employeeName)

With a TRAVERSE (it will also traverse hierarchies, in case a company
belongs to another company and so on...)

SELECT FROM (
   TRAVERSE out("provides", "belongs_to") FROM (
       SELECT FROM Employee WHERE name = :employeeName
   )
WHERE @class = 'Insurance'


I hope it helps

Thanks

Luigi

Il giorno mer 5 dic 2018 alle ore 09:05 axon musthaq <[email protected]>
ha scritto:

>
> 1.I have a vertex class employee which contain employee_details
> 2.I have a vertex class organization which contain organization_details
> 3.I have a vertex class insurance which contain insurance_details
>
> following are the relationship
>
> employee-out('belongs_to')->organization-out('provides')->insurance
>
> eg:sam-out('belongs_to')->'XXX'-out('provides')->medical
>
> but some employee have direct relationship with insurance class without
> organization
>
> employee-out('provides')->insurance
>
> eg:john-out('provides')->health
>
> i need to write a query to show employee with their insurance irrespective
> of organization
>
> output:
>
> EmployeeName           Organization          Insurance
>
> sam                               XXX                     medical
> john                                                            health
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "OrientDB" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to