Subqueries Adding the  LATERAL  keyword makes the query legal: In short,  LATERAL  is the efficient solution to all drawbacks in the two approaches just discussed. SELECT salesperson.name, max_sale.amount, max_sale.customer_name FROM salesperson, -- find maximum size and customer at same time LATERAL (SELECT amount, customer_name FROM all_sales WHERE all_sales.salesperson_id = salesperson.id ORDER BY amount DESC LIMIT 1) AS max_sale; 13.2.11.10 Subquery Errors There are some errors that apply only to subqueries. This section describes them. This means that MySQL does not support statements like the following: •Unsupported subquery syntax: •Incorrect number of columns from subquery: ERROR 1235 (ER_NOT_SUPPORTED_YET) SQLSTATE = 42000 Message = "This version of MySQL doesn’t yet support ’LIMIT & IN/ALL/ANY/SOME subquery’" SELECT * FROM t1 WHERE s1 IN (SELECT s2 FROM t2 ORDER BY s1 LIMIT 1) ERROR 1241 (ER_OPERAND_COL) SQLSTATE = 21000 Message = "Operand should contain 1 column(s)" SELECT (SELECT column1, column2 FROM t2) FROM t1; ERROR 1242 (ER_SUBSELECT_NO_1_ROW) SQLSTATE = 21000 Message = "Subquery returns more than 1 row" SELECT * FROM t1 WHERE column1 = (SELECT column1 FROM t2); SELECT * FROM t1 WHERE column1 = ANY (SELECT column1 FROM t2); •Incorrectly used table in subquery: •Incorrect number of rows from subquery: This error occurs in cases like this: You may use a subquery that returns multiple columns, if the purpose is row comparison. In other contexts, the subquery must be a scalar operand. See Section 13.2.11.5, “Row Subqueries” . This error occurs for statements where the subquery must return at most one row but returns multiple rows. Consider the following example: If  SELECT column1 FROM t2  returns just one row, the previous query works. If the subquery returns more than one row, error 1242 occurs. In that case, the query should be rewritten as: 2697