1
0
Fork 0
arangodb/Documentation/Books/Users/AqlExamples
Wilfried Goesgens 1e54b063ee Add a subquery example that combines geo indices with graph traversals. 2015-12-08 19:34:23 +01:00
..
CollectionQueries.mdpp Fix dangling anchors and add checker script to the make target. 2015-11-26 18:51:39 +01:00
CombiningGraphTraversals.mdpp Add a subquery example that combines geo indices with graph traversals. 2015-12-08 19:34:23 +01:00
DataModificationQueries.mdpp Remove whitespaces that may irretate our parser, add checks. 2015-12-04 15:17:36 +01:00
Grouping.mdpp Documentation: corrected typos and case, prefer American over British English 2015-09-01 17:19:13 +02:00
Join.mdpp Documentation: corrected typos and case, prefer American over British English 2015-09-01 17:19:13 +02:00
ProjectionsAndFilters.mdpp
README.mdpp

README.mdpp

!CHAPTER AQL Examples

This page contains some examples how to write queries in AQL. For better
understandability the query results are also included directly below each query.

!SECTION Simple queries

Following is a query that returns a string value. The result string is contained in an array
because the result of every valid query is an array:

```js
RETURN "this will be returned"
[ 
  "this will be returned" 
]
```

Here is a query that creates the cross products of two arrays and runs a projection 
on it, using a few of AQL's built-in functions:

```js
FOR year in [ 2011, 2012, 2013 ]
  FOR quarter IN [ 1, 2, 3, 4 ]
    RETURN { 
      "y" : "year", 
      "q" : quarter, 
      "nice" : CONCAT(TO_STRING(quarter), "/", TO_STRING(year)) 
    }
[ 
  { "y" : "year", "q" : 1, "nice" : "1/2011" }, 
  { "y" : "year", "q" : 2, "nice" : "2/2011" }, 
  { "y" : "year", "q" : 3, "nice" : "3/2011" }, 
  { "y" : "year", "q" : 4, "nice" : "4/2011" }, 
  { "y" : "year", "q" : 1, "nice" : "1/2012" }, 
  { "y" : "year", "q" : 2, "nice" : "2/2012" }, 
  { "y" : "year", "q" : 3, "nice" : "3/2012" }, 
  { "y" : "year", "q" : 4, "nice" : "4/2012" }, 
  { "y" : "year", "q" : 1, "nice" : "1/2013" }, 
  { "y" : "year", "q" : 2, "nice" : "2/2013" }, 
  { "y" : "year", "q" : 3, "nice" : "3/2013" }, 
  { "y" : "year", "q" : 4, "nice" : "4/2013" } 
]
```