Thanks for the quick response. It is throwing the following error: com.orientechnologies.orient.core.exception.OValidationException: The field 'Zipcodes.state' has been declared as LINK but the value is not a record or a record-id
I switch the field from "Zipcodes.state" to "Zipcodes.state_tmp" to see what was the output. It seems the output is "[0]". I also tried the following but none of them seemed to work: UPDATE Zipcodes SET state=(SELECT @rid FROM States WHERE id= *$parent.state_id*) UPDATE Zipcodes SET state=(SELECT @rid FROM States WHERE id=$parent.$record.state_id)*[0]* UPDATE Zipcodes SET state=(SELECT @rid *AS rid* FROM States WHERE id=$parent.$record.state_id)*.rid* UPDATE Zipcodes SET state=(SELECT @rid *AS rid* FROM States WHERE id=$parent.$record.state_id)*.result[0].rid* UPDATE Zipcodes SET state=(SELECT @rid *AS state* FROM States WHERE id=$parent.$record.state_id) On Monday, January 13, 2014 12:09:20 PM UTC-5, Lvc@ wrote: > > Hi, > to get the upper level context variable you've to use $parent.record. > Example: > > UPDATE Zipcodes SET state=(SELECT @rid FROM States WHERE > id=$parent.$record.state_id); > > I never tried with UPDATE but should work. > > Lvc@ > > > > On 13 January 2014 18:00, Giraldo Rosales <[email protected] > <javascript:>>wrote: > >> How do we nest queries? Trying to do an update. Have two types of >> documents, zip codes and states. There are two fields in particular in the >> zip code document: "state_id" (String) and "state" (Link). Would like to >> add SELECT the "id" field in the state documents and insert the RID if it >> matches. >> >> I would have thought something like: >> UPDATE Zipcodes SET state=(SELECT @rid FROM States WHERE >> id=Zipcodes.state_id); >> >> Where Zipcodes.state_id is a field in Zipcodes and would match the field, >> States.id. It would then select the RID in States and insert it in the >> ZIpcodes.state field (Link). >> >> In MySQL examples are here: >> http://dev.mysql.com/doc/refman/5.0/en/subqueries.html >> >> How is this done in OrientDB? Saw something with the LET command but >> doesn't seem to work with updates. >> >> Thanks! >> >> -- >> >> --- >> 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/groups/opt_out. >> > > -- --- 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/groups/opt_out.
