Hi Julian,
first of all let's make your query work, this is the right one:
select from FOrder where user IN (select @rid from FUser where userId = "642255")
Please note that I used IN operator instead of = because a query returns a result set, that is a collection.
But all this is just for the record, now let's move to the real problem. You are using OrientDB as if it were a relational database, in the end you are doing a JOIN (!!!) while you could have direct links (document) or edges (graph).
If you change your domain to be more "graph", you would have this (just an example)
Class FOrder extends V (vertex)
Class FUser extends V (vertex)
Class Ordered extends E (edge)
your data structure would be something like
FUser --Ordered--> FOrder
and your query would be something like
select out("Ordered") from FUser where where userId = "642255"
This query, in addition to being more readable, is also more efficient than the previous one, because it relies on an index only to find the user based on its userId, and then uses the "Ordered" edge to find linked orders. This last operation (the graph traversal) is a constant time operation ( O(1), while index search is O(log N) ), that means that having a graph with 10 vertexes or having one of 10.000.000.000 is exactly the same in terms of traversal time
Luigi