Thanks Luigi, it worked. I didn't think in terms of a resultset, but it makes sense.
On Tuesday, October 25, 2016 at 11:51:21 PM UTC-7, Luigi Dell'Aquila wrote: > > Hi, > > The result of a subquery is a result-set, not a single element. I think > that rewriting the query this way it should work fine: > > select from B let $aa = (select from A where id = 1) where $aa contains a > > Thanks > > Luigi > > 2016-10-26 8:43 GMT+02:00 Oleksandr Gubchenko <[email protected] > <javascript:>>: > >> Can you try this one? >> >> select $aa.@rid, a from B >> let $aa = (select from A where id = 1) >> >> >> >> Il giorno mercoledì 26 ottobre 2016 08:37:19 UTC+2, [email protected] ha >> scritto: >>> >>> >>> Hello, >>> >>> I seem to run into a wall while trying to figure the LET statement which >>> is just failing on me, Here are 2 classes where one has link to another. I >>> need to use the LET statement to get the linked class by provided id, but >>> the result never returns any records. Sub query does return the result >>> correctly, but not the query with the LET statement. >>> >>> My classes: >>> >>> create class A extends V >>> create property A.id INTEGER (NOTNULL TRUE, MANDATORY TRUE) >>> >>> create class B extends V >>> create property B.a LINK A (NOTNULL TRUE, MANDATORY TRUE) >>> >>> insert into A (id) values (1) >>> insert into B set a = (select from A where id = 1) >>> >>> select from B let $aa = (select from A where id = 1) where a = $aa >>> select from B let $aa = (select from A where id = 1) where a = $aa.@rid >>> >>> >>> Here is the data >>> >>> orientdb {db=Customers}> select from A >>> >>> +----+------+------+----+ >>> |# |@RID |@CLASS|id | >>> +----+------+------+----+ >>> |0 |#185:0|A |1 | >>> +----+------+------+----+ >>> >>> 1 item(s) found. Query executed in 0.002 sec(s). >>> orientdb {db=Customers}> insert into B set a = (select from A where id >>> = 1) >>> >>> Inserted record 'B#189:0{a:#185:0} v1' in 0.004000 sec(s). >>> >>> orientdb {db=Customers}> select from B >>> >>> +----+------+------+------+ >>> |# |@RID |@CLASS|a | >>> +----+------+------+------+ >>> |0 |#189:0|B |#185:0| >>> +----+------+------+------+ >>> >>> >>> As you can see from above, class B has a link to class A. In my >>> understanding the query below must work, but it returns nothing. I tried 2 >>> combinations of the query and both don't work. >>> >>> orientdb {db=Customers}> select from B let $aa = (select from A where id >>> = 1) where a = $aa >>> >>> 0 item(s) found. Query executed in 0.003 sec(s). >>> >>> orientdb {db=Customers}> select from B let $aa = (select from A where >>> id = 1) where a = $aa.@rid >>> >>> 0 item(s) found. Query executed in 0.003 sec(s). >>> >>> >>> >>> Am I doing something wrong or is it a bug? >>> >>> -- >> >> --- >> 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] <javascript:>. >> 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.
