You can use 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, view, associative table, or subquery.
  • Table names and column names are not case-sensitive.
  • If a table name or column name contains keywords or spaces, you can quote the table name or column name with backticks (``).

WHERE

You can enter a BOOLEAN expression following the WHERE keyword to query data records that meet the specified condition. For example, you can execute the following statement to query the information of 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, indicating 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;          

The following methods show you how to use other keywords: