Next revision | Previous revisionNext revisionBoth sides next revision |
documentation:tutorials:json_query [2013/02/26 17:48] – this is a rough conversion from openoffice format lebbeous | documentation:tutorials:json_query [2018/11/26 12:27] – Remove unnecessary "nowiki" tag from within code tag rjs7 |
---|
| |
| |
- The entire JSON query is an object. In this simple case the object includes only one entry, for the FROM clause. Typically you'll also have entries for the SELECT clause and the WHERE clause, and possibly for HAVING, ORDER BY, LIMIT, or OFFSET clauses. There is no separate entry for a GROUP BY clause, which you can specify by other means. | * The entire JSON query is an object. In this simple case the object includes only one entry, for the FROM clause. Typically you'll also have entries for the SELECT clause and the WHERE clause, and possibly for HAVING, ORDER BY, LIMIT, or OFFSET clauses. There is no separate entry for a GROUP BY clause, which you can specify by other means. |
| |
- Although all the other entries are optional, you must include an entry for the FROM clause. You cannot, for example, do a SELECT USER the way you can in psql. | * Although all the other entries are optional, you must include an entry for the FROM clause. You cannot, for example, do a SELECT USER the way you can in psql. |
| |
- Every column is qualified by an alias for the table. This alias is usually the class name for the table, as defined in the IDL, but you can use an alias of your own choosing for a table in a JOIN clause (not shown here). | * Every column is qualified by an alias for the table. This alias is usually the class name for the table, as defined in the IDL, but you can use an alias of your own choosing for a table in a JOIN clause (not shown here). |
| |
- Every column is aliased with the column name. There is a way to choose a different column alias (not shown here). | |
| |
| * Every column is aliased with the column name. There is a way to choose a different column alias (not shown here). |
===== The SELECT clause ===== | ===== The SELECT clause ===== |
| |
| |
| |
- "column" -- the column name (required). | * "column" -- the column name (required). |
| |
- "alias" -- used to define a column alias, which otherwise defaults to the column name. | * "alias" -- used to define a column alias, which otherwise defaults to the column name. |
| |
- "aggregate" -- takes a value of true or false. Don't worry about this one yet. It concerns the use of GROUP BY clauses, which we will examine later. | * "aggregate" -- takes a value of true or false. Don't worry about this one yet. It concerns the use of GROUP BY clauses, which we will examine later. |
| |
- "transform" -- the name of an SQL function to be called. | * "transform" -- the name of an SQL function to be called. |
| |
- "result_field" -- used with "transform"; specifies an output column of a function that returns multiple columns at a time. | * "result_field" -- used with "transform"; specifies an output column of a function that returns multiple columns at a time. |
| |
- "params" -- used with "transform"; provides a list of parameters for the function. They may be strings, numbers, or nulls. | * "params" -- used with "transform"; provides a list of parameters for the function. They may be strings, numbers, or nulls. |
| |
This example assigns a different column alias: | This example assigns a different column alias: |
JOIN actor.org_unit AS s ON (t.source = s.id) | JOIN actor.org_unit AS s ON (t.source = s.id) |
JOIN actor.org_unit AS d ON (t.dest = d.id) | JOIN actor.org_unit AS d ON (t.dest = d.id) |
WHERE s.parent_ou<nowiki> <> </nowiki>d.parent_ou ) AS "iatc" ; | WHERE s.parent_ou <> d.parent_ou ) AS "iatc" ; |
| |
</code> | </code> |