name in the SELECT  statement, a locking clause may only use the alias. If the SELECT  statement does not specify an alias explicitly, the locking clause may only specify the actual table name. 

For more information about FOR UPDATE  and FOR SHARE , see Section 15.7.2.4, “Locking Reads” . For additional information about NOWAIT  and SKIP LOCKED  options, see Locking Read Concurrency with NOWAIT and SKIP LOCKED. 

Following the SELECT  keyword, you can use a number of modifiers that affect the operation of the statement. HIGH_PRIORITY , STRAIGHT_JOIN , and modifiers beginning with SQL_  are MySQL extensions to standard SQL. 

•The ALL  and DISTINCT  modifiers specify whether duplicate rows should be returned. ALL  (the default) specifies that all matching rows should be returned, including duplicates. DISTINCT  specifies removal of duplicate rows from the result set. It is an error to specify both modifiers. DISTINCTROW  is a synonym for DISTINCT . 

In MySQL 8.0.12 and later, DISTINCT  can be used with a query that also uses WITH ROLLUP . (Bug #87450, Bug #26640100) 

• HIGH_PRIORITY  gives the SELECT  higher priority than a statement that updates a table. You should use this only for queries that are very fast and must be done at once. A SELECT HIGH_PRIORITY query that is issued while the table is locked for reading runs even if there is an update statement waiting for the table to be free. This affects only storage engines that use only table-level locking (such as MyISAM , MEMORY , and MERGE ). 

HIGH_PRIORITY  cannot be used with SELECT  statements that are part of a UNION . 

• STRAIGHT_JOIN  forces the optimizer to join the tables in the order in which they are listed in the FROM  clause. You can use this to speed up a query if the optimizer joins the tables in nonoptimal order. STRAIGHT_JOIN  also can be used in the table_references  list. See Section 13.2.10.2, “JOIN Clause” . 

STRAIGHT_JOIN  does not apply to any table that the optimizer treats as a const  or system  table. Such a table produces a single row, is read during the optimization phase of query execution, and references to its columns are replaced with the appropriate column values before query execution proceeds. These tables appear first in the query plan displayed by EXPLAIN . See Section 8.8.1, “Optimizing Queries with EXPLAIN” . This exception may not apply to const  or system  tables that are used on the NULL -complemented side of an outer join (that is, the right-side table of a LEFT JOIN  or the left-side table of a RIGHT JOIN . 

• SQL_BIG_RESULT  or SQL_SMALL_RESULT  can be used with GROUP BY  or DISTINCT  to tell the optimizer that the result set has many rows or is small, respectively. For SQL_BIG_RESULT , MySQL directly uses disk-based temporary tables if they are created, and prefers sorting to using a temporary table with a key on the GROUP BY  elements. For SQL_SMALL_RESULT , MySQL uses in-memory temporary tables to store the resulting table instead of using sorting. This should not normally be needed. 

• SQL_BUFFER_RESULT  forces the result to be put into a temporary table. This helps MySQL free the table locks early and helps in cases where it takes a long time to send the result set to the client. This modifier can be used only for top-level SELECT  statements, not for subqueries or following UNION . 

• SQL_CALC_FOUND_ROWS  tells MySQL to calculate how many rows there would be in the result set, disregarding any LIMIT  clause. The number of rows can then be retrieved with SELECT FOUND_ROWS() . See Section 12.16, “Information Functions” . 

