Index...
Centrallix Documentation
|
6.9 Subqueries
SQL Subqueries
Centrallix supports SQL subqueries, which are entire SQL statements embedded within an expression, either within another SQL statement or elsewhere within Centrallix.
Subqueries can be entirely independent of the expression or query in which they occur, or they may also reference values from the containing query or framework. This latter form of a subquery is called a correlated subquery.
Example (find all files taking up 10% or more of the space in a directory):
SELECT :f1:name, :f1:size
FROM /public/directory f1
WHERE :f1:size >= (SELECT sum(:f2:size) / 10 FROM /public/directory f2)
Note that if you don't give the data source an alias ("f2" in this case) in the subquery, you may need to put a space between the data source path and the closing parenthesis so that the closing parenthesis is not interpreted as a part of the pathname.
UPDATE, DELETE, and INSERT statements may not be used in a subquery. Only SELECT statements may be used in a subquery.
Comments...
(none yet)
Add a Comment...
|