A SELECT statement selects data from tables.

Syntax

SELECT [ DISTINCT ]
{ * | projectItem [, projectItem ]* }
FROM tableExpression;

Subqueries

Generally, a SELECT statement reads data from several tables, such as SELECT column_1, column_2 ... FROM table_name. A SELECT statement can also read data from another SELECT statement, which is called a subquery.
Notice A subquery must use an alias, as shown in the following example.
INSERT INTO result_table
SELECT * FROM(
  SELECT t.a, 
    sum(t.b) AS sum_b
  FROM t
  GROUP BY t.a) t1 
WHERE  t1.sum_b > 100;