The FROM clause is used to specifyg source and any joined sources.
FROM <from_specification>
<from_specification> ::=
<from_source> {[ JOIN <from_source>][,...n]}
<from_source> ::=
<collection_expression> [[AS] input_alias]
| input_alias IN <collection_expression>
<collection_expression> ::=
ROOT
| collection_name
| input_alias
| <collection_expression> '.' property_name
| <collection_expression> '[' "property_name" | array_index ']'
<from_source>
Specifies a data source, with or without an alias. If alias is not specified, it will be inferred from the <collection_expression> using following rules:
SELECT css("#title") FROM http://www.delven.io/test/index-01.html
SELECT css('#title') as title
FROM
(
SELECT css('#root-selector') FROM http://www.delven.io/test/index-01.html
) AS T1
When this query run, the subquery is first run and the results created. The results are then used in the FROM clause.
This is equivalent to using a subquery version
SELECT css('#title') as title
FROM css('#root-selector')
WITHIN http://www.delven.io/test/index-01.html
Here we simply select data from two separate soures and return them.
SELECT * FROM
(
SELECT css("#title") as title, css("#title a") as links
FROM http://www.delven.io/test/index-01.html
) AS T1 ,
(
SELECT css("#title") as title, css("#title a") as links
FROM http://www.delven.io/test/index-02.html
) AS T2
You can also join two derived tables together using WHERE
clause or a JOIN
clause.
WHERE
clauseSELECT * FROM
(
SELECT css("#title") as title, css("#title a") as links
FROM http://www.delven.io/test/index-01.html
) AS T1
,
(
SELECT css("#title") as title, css("#title a") as links
FROM http://www.delven.io/test/index-02.html
) AS T2
WHERE T1.title = T2.title
JOIN
clauseSELECT * FROM
(
SELECT css("#title") as title, css("#title a") as links
FROM http://www.delven.io/test/index-01.html
) AS T1
JOIN
(
SELECT css("#title") as title, css("#title a") as links
FROM http://www.delven.io/test/index-02.html
) AS T2 AS ON
{
"left" : {"title" : T1.title},
"right" : {"title" : T2.title}
}
WHERE T1.css("#title").contains("Comment")