SELECT Statement SET @a=1; PREPARE STMT FROM ’SELECT * FROM tbl LIMIT ?’; EXECUTE STMT USING @a; SET @skip=1; SET @numrows=5; PREPARE STMT FROM ’SELECT * FROM tbl LIMIT ?, ?’; EXECUTE STMT USING @skip, @numrows; The following statements return the second to sixth rows from the  tbl  table: For compatibility with PostgreSQL, MySQL also supports the  LIMIT  row_count  OFFSET  offset syntax. If  LIMIT  occurs within a parenthesized query expression and also is applied in the outer query, the results are undefined and may change in a future version of MySQL. •The  SELECT ... INTO  form of  SELECT  enables the query result to be written to a file or stored in variables. For more information, see Section 13.2.10.1, “SELECT ... INTO Statement” . • If you use  FOR UPDATE  with a storage engine that uses page or row locks, rows examined by the query are write-locked until the end of the current transaction. You cannot use  FOR UPDATE  as part of the  SELECT  in a statement such as  CREATE TABLE new_table  SELECT ... FROM  old_table  ... . (If you attempt to do so, the statement is rejected with the error  Can’t update table ’ old_table ’ while ’ new_table ’ is being created .) FOR SHARE  and  LOCK IN SHARE MODE  set shared locks that permit other transactions to read the examined rows but not to update or delete them.  FOR SHARE  and  LOCK IN SHARE MODE  are equivalent. However,  FOR SHARE , like  FOR UPDATE , supports  NOWAIT ,  SKIP LOCKED , and  OF tbl_name  options.  FOR SHARE  is a replacement for  LOCK IN SHARE MODE , but  LOCK IN SHARE MODE  remains available for backward compatibility. NOWAIT  causes a  FOR UPDATE  or  FOR SHARE  query to execute immediately, returning an error if a row lock cannot be obtained due to a lock held by another transaction. SKIP LOCKED  causes a  FOR UPDATE  or  FOR SHARE  query to execute immediately, excluding rows from the result set that are locked by another transaction. NOWAIT  and  SKIP LOCKED  options are unsafe for statement-based replication. Queries that skip locked rows return an inconsistent view of the data.  SKIP LOCKED  is therefore not suitable for general transactional work. However, it may be used to avoid lock contention when multiple sessions access the same queue- like table. Note All tables referenced by the query block are locked when  OF  tbl_name  is omitted. Consequently, using a locking clause without  OF  tbl_name  in combination with another locking clause returns an error. Specifying the same table in multiple locking clauses returns an error. If an alias is specified as the table SELECT * FROM t1, t2 FOR SHARE OF t1 FOR UPDATE OF t2; OF  tbl_name  applies  FOR UPDATE  and  FOR SHARE  queries to named tables. For example: