I'm using SQL with Orient DB version 2.2. I want to merge elements of a class when they have the same ID and append the attribute of the one element to the attribute of the other one. This attribute is of type "embeddedset".
Let's assume I have 3 elements of the same class like this
+-------+------------+--------------+
| Elem | ID | setAttribute |
+-------+------------+--------------+
| 1 | id1 | name1 |
| 2 | id2 | name1 |
| 3 | id1 | name2 |
+-------+------------+--------------+
I want to end up with this:
+-------+------------+--------------+
| Elem | ID | setAttribute |
+-------+------------+--------------+
| 1 | id1 | name1, name2 |
| 2 | id2 | name1 |
+-------+------------+--------------+
I tried as a start to find all the matches:
SELECT FROM (MATCH {class:elementClass,as:element1}, {class:elementClass, as:element2} RETURN element1, element2) WHERE (element1.id == element2.id AND element1.@rid <> element2.@rid)
However, unfortunately I dont know how to continue? Thanks a lot!
You can try like below
select Elem, ID, $a.setAttribute from
(select from t )
let $a=(select from t where ID=$parent.current.ID)
group by ID
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.