You can execute the SELECT statement to query data from one or more tables. The following syntax is used:

[ WITH with_query [, ...] ]
SELECT
[ ALL | DISTINCT ] select_expr [, ...]
[ FROM table_reference [, ...] ]
[ WHERE condition ]
[ GROUP BY [ ALL | DISTINCT ] grouping_element [, ...] ]
[ HAVING condition]
[ WINDOW window_name AS (window_spec) [, window_name AS (window_spec)] ...]
[ { UNION | INTERSECT | EXCEPT } [ ALL | DISTINCT ] select ]
[ ORDER BY {column_name | expr | position} [ASC | DESC], ... [WITH ROLLUP]]
[LIMIT {[offset,] row_count | row_count OFFSET offset}]       
  • table_reference: the data source from which data is queried. The source can be a table, a view, an associative table, or a subquery.
  • Table names and column names are not case-sensitive.
  • If a table name or a column name contains keywords or spaces, you can enclose the table name or the column name by using backticks (``).

WHERE

You can enter a BOOLEAN expression that follows the WHERE keyword to query data records that meet the specified condition. For example, you can execute the following statement to query the information about the customer whose customer_id is 2368:

SELECT * FROM CUSTOMER where customer_id=2368;          

ALL and DISTINCT

You can use the ALL and DISTINCT keywords to specify whether duplicate rows are returned in the query result. The default value is ALL, which indicates that all rows are returned. The DISTINCT keyword indicates that duplicate rows are deleted from the query result.

SELECT col1, col2 FROM t1;
SELECT DISTINCT col1, col2 FROM t1;          

You can click the following links to obtain information about other keywords in the SELECT statement: