FROM
Specifies the tables or views to be used in a SELECT statement.
See also: CONNECT BY, JOIN, Join Guide.
Syntax
sql
SELECT ...
FROM obj_ref [JOIN obj_ref [...]]
[...]Where:
sql
obj_ref ::=
{
folder_name.obj_name
[[AS] alias]
}Clauses and Parameters
JOIN subclause: Creates a relationship between two or more tables (or views). All supported types of JOINs can be used. Alternative JOIN syntaxes are also supported.
[AS] alias: Defines an alias name for the object. AS can be used in combination with all other subclauses in the FROM clause.
folder_name.obj_name: Specifies the name of the object (table or view) to be queried.
Usage Notes
- For working with hierarchical query results, see CONNECT BY.
- Object names are SQL identifiers. By default, they are case-insensitive. To use case-sensitive references, enclose object names in double quotes (
" ").
Example 1 | Simple FROM Query
sql
WITH
prod_table AS (
SELECT * FROM (
SELECT 'a hoe' AS prod_name,
14.99 AS price,
2.99 AS delivery_costs
)
)
SELECT prod_name, price, delivery_costs FROM prod_table;+-------------+--------------+----------------+
| PROD_NAME | PRICE | DELIVERY_COSTS |
|-------------+--------------+----------------|
| a hoe | 14.99 | 2.99 |
+-------------+--------------+----------------+Example 2 | Query Using folder_name. Qualifier
sql
CREATE TABLE mkw_doku.my_table1 (ord STRING, col1 INTEGER);
INSERT INTO mkw_doku.my_table1 (ord, col1) VALUES ('a', 10);
INSERT INTO mkw_doku.my_table1 (ord, col1) VALUES ('b', 20);
INSERT INTO mkw_doku.my_table1 (ord, col1) VALUES ('c', 30);
SELECT ord, col1
FROM mkw_doku.my_table1;+-----+------+
| ORD | COL1 |
+-----+------+
| a | 10 |
| b | 20 |
| c | 30 |
+-----+------+Example 3 | Query Using an Inline View
sql
WITH
prod_table AS (
SELECT * FROM (
SELECT 'a hoe' AS prod_name,
14.99 AS price,
2.99 AS delivery_costs
)
)
SELECT prod_view.prod_name, prod_view.full_costs
FROM (
SELECT prod_name, price + delivery_costs AS full_costs
FROM prod_table
) prod_view;+-------------+--------------+
| PROD_NAME | FULL_COSTS |
|-------------+--------------|
| a hoe | 17.98 |
+-------------+--------------+