content_image/869657.jpg
<img src='content_image/869657.jpg'>

## Note 

The SQL_CALC_FOUND_ROWS  query modifier and accompanying FOUND_ROWS() function are deprecated as of MySQL 8.0.17; expect them to be removed in a future version of MySQL. See the FOUND_ROWS()  description for information about an alternative strategy. 

•The SQL_CACHE  and SQL_NO_CACHE  modifiers were used with the query cache prior to MySQL 8.0. The query cache was removed in MySQL 8.0. The SQL_CACHE  modifier was removed as well. SQL_NO_CACHE  is deprecated, and has no effect; expect it to be removed in a future MySQL release. 

## 13.2.10.1 SELECT ... INTO Statement 

The SELECT ... INTO  form of SELECT  enables a query result to be stored in variables or written to a file: 

• SELECT ... INTO var_list  selects column values and stores them into variables. 

• SELECT ... INTO OUTFILE  writes the selected rows to a file. Column and line terminators can be specified to produce a specific output format. 

• SELECT ... INTO DUMPFILE  writes a single row to a file without any formatting. 

A given SELECT  statement can contain at most one INTO  clause, although as shown by the SELECT syntax description (see Section 13.2.10, “SELECT Statement” ), the INTO  can appear in different positions: 

•Before FROM . Example: 

SELECT * INTO @myvar FROM t1; 

•Before a trailing locking clause. Example: 

SELECT * FROM t1 INTO @myvar FOR UPDATE; 

•At the end of the SELECT . Example: 

SELECT * FROM t1 FOR UPDATE INTO @myvar; 

The INTO  position at the end of the statement is supported as of MySQL 8.0.20, and is the preferred position. The position before a locking clause is deprecated as of MySQL 8.0.20; expect support for it to be removed in a future version of MySQL. In other words, INTO  after FROM  but not at the end of the SELECT produces a warning. 

An INTO  clause should not be used in a nested SELECT  because such a SELECT  must return its result to the outer context. There are also constraints on the use of INTO  within UNION  statements; see Section 13.2.10.3, “UNION Clause” . 

For the INTO var_list  variant: 

• var_list  names a list of one or more variables, each of which can be a user-defined variable, stored procedure or function parameter, or stored program local variable. (Within a prepared SELECT ... INTO var_list  statement, only user-defined variables are permitted; see Section 13.6.4.2, “Local Variable Scope and Resolution” .) 

•The selected values are assigned to the variables. The number of variables must match the number of columns. The query should return a single row. If the query returns no rows, a warning with error code 1329 occurs ( No data ), and the variable values remain unchanged. If the query returns multiple rows, 

