Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OrientDB - Update with SUBSELECT

Tags:

orientdb

I want to update some rows of my table basing on other rows of the same table:

I try this:

UPDATE MyTable set myField = 
    (SELECT T1.myField
    FROM MyTable T1
    WHERE T1.id.substring(start,stop) = MyTable.id.substring(start,stop))

But OrientDB throws an error like this:

com.orientechnologies.orient.core.sql.OCommandSQLParsingException: Error on parsing command at position #XXX: Invalid keyword 'T1' Command:

like image 482
Joe Taras Avatar asked Dec 15 '25 02:12

Joe Taras


1 Answers

first of all you in OrientDB you can't use Alias on Classes.

In this case you could use $parent.$current in a subquery, something like:

> update MyTable set myField = (
>         select myField
>         from MyTable
>         where myField is null
>         and id.substring(8,13) = $parent.$current.id.substring(8,13) and something else...
>          ) where myField is null and something else...

Be careful to the length of the id...

Best Regards M.

like image 154
Marcus Avatar answered Dec 16 '25 18:12

Marcus