简体   繁体   中英

AQL- expected join possible in Arangodb and How?

My Environment

  • ArangoDB Version: 3.5.2(the latest i think)
  • Storage Engine:RocksDB
  • Deployment Mode:Single Server
  • Deployment Strategy: Manual Start
  • Infrastructure:own
  • Operating System: Ubuntu 16.04
  • Total RAM in your machine: 8GB
  • Disks in use: 256GB

Problem : I have 2 collection and i have to perform join and want expected result is that possible in Arangodb ??

collection 1 :[
                { id :1 , name: "jack" },
                { id :2 , name: "ryan" },
                { id :3 , name: "sam" },
                { id :4 , name: "rick" },
                { id :5 , name: "jackie" },
                { id :6 , name: "roman" },
                { id :7 , name: "soul" },
                { id :8 , name: "brad" }
              ]  
collection 2 :[
                 { id :1 ,age:12 ,standard: 5 },
                 { id :5 ,age:14 ,standard: 7 },
                 { id :7,age:15 ,standard: 8 }
              ]

Expected result :

[
        { id :1 , name: "jack",standard: 5  },
        { id :2 , name: "ryan",standard: 5  },
        { id :3 , name: "sam" ,standard: 5 },
        { id :4 , name: "rick",standard: 5  },
        { id :5 , name: "jackie",standard: 7  },
        { id :6 , name: "roman",standard: 7  },
        { id :7 , name: "soul",standard: 8  },
        { id :8 , name: "brad",standard: 8  }
]

You could try

FOR item in collection_1
    FOR item2 in collection_2
        FILTER item.id == item2.id
        RETURN MERGE(item, item2)

You can check the documentation: https://www.arangodb.com/docs/stable/aql/examples-join.html

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM