Subqueries id: 2 select_type: DERIVED table: NULL partitions: NULL type: NULL possible_keys: NULL key: NULL key_len: NULL ref: NULL rows: NULL filtered: NULL Extra: No tables used 3 rows in set (0.00 sec) mysql>  SELECT * FROM t2; +------+ | c1 | +------+ | 5 | +------+ 1 row in set (0.00 sec) 13.2.11.9 Lateral Derived Tables 2694 This also means that an  EXPLAIN SELECT  statement such as the one shown here may take a long time to execute because the  BENCHMARK()  function is executed once for each row in  t1 : EXPLAIN SELECT * FROM t1 AS a1, (SELECT BENCHMARK(1000000, MD5(NOW()))); The derived table optimization can also be employed with many correlated (scalar) subqueries (MySQL 8.0.24 and later). For more information and examples, see Section 13.2.11.7, “Correlated Subqueries” . A derived table cannot normally refer to (depend on) columns of preceding tables in the same  FROM clause. As of MySQL 8.0.14, a derived table may be defined as a lateral derived table to specify that such references are permitted. Nonlateral derived tables are specified using the syntax discussed in Section 13.2.11.8, “Derived Tables” . The syntax for a lateral derived table is the same as for a nonlateral derived table except that the keyword LATERAL  is specified before the derived table specification. The  LATERAL  keyword must precede each table to be used as a lateral derived table. Lateral derived tables are subject to these restrictions: •A lateral derived table can occur only in a  FROM  clause, either in a list of tables separated with commas or in a join specification ( JOIN ,  INNER JOIN ,  CROSS JOIN ,  LEFT [OUTER] JOIN , or  RIGHT [OUTER] JOIN ). •If a lateral derived table is in the right operand of a join clause and contains a reference to the left operand, the join operation must be an  INNER JOIN ,  CROSS JOIN , or  LEFT [OUTER] JOIN . •If a lateral derived table references an aggregate function, the function’s aggregation query cannot be the one that owns the  FROM  clause in which the lateral derived table occurs. •Per the SQL standard, a table function has an implicit  LATERAL , so it behaves as in MySQL 8.0 versions prior to 8.0.14. However, per the standard, the  LATERAL  word is not allowed before  JSON_TABLE() , even though it is implicit. If the table is in the left operand and contains a reference to the right operand, the join operation must be an  INNER JOIN ,  CROSS JOIN , or  RIGHT [OUTER] JOIN .