content_image/741430.jpg
the pages that show other sections of a search result. Using FOUND_ROWS()  enables you to determine how many other pages are needed for the rest of the result. 

The use of SQL_CALC_FOUND_ROWS  and FOUND_ROWS()  is more complex for UNION  statements than for simple SELECT  statements, because LIMIT  may occur at multiple places in a UNION . It may be applied to individual SELECT  statements in the UNION , or global to the UNION  result as a whole. 

The intent of SQL_CALC_FOUND_ROWS  for UNION  is that it should return the row count that would be returned without a global LIMIT . The conditions for use of SQL_CALC_FOUND_ROWS  with UNION  are: 

•The SQL_CALC_FOUND_ROWS  keyword must appear in the first SELECT  of the UNION . 

•The value of FOUND_ROWS()  is exact only if UNION ALL  is used. If UNION  without ALL  is used, duplicate removal occurs and the value of FOUND_ROWS()  is only approximate. 

•If no LIMIT  is present in the UNION , SQL_CALC_FOUND_ROWS  is ignored and returns the number of rows in the temporary table that is created to process the UNION . 

Beyond the cases described here, the behavior of FOUND_ROWS()  is undefined (for example, its value following a SELECT  statement that fails with an error). 

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

• ICU_VERSION() 

## Important 

FOUND_ROWS()  is not replicated reliably using statement-based replication. This function is automatically replicated using row-based replication. 

The version of the International Components for Unicode (ICU) library used to support regular expression operations (see Section 12.8.2, “Regular Expressions” ). This function is primarily intended for use in test cases. 

• LAST_INSERT_ID() , LAST_INSERT_ID( expr ) 

With no argument, LAST_INSERT_ID()  returns a BIGINT UNSIGNED  (64-bit) value representing the first automatically generated value successfully inserted for an AUTO_INCREMENT  column as a result of the most recently executed INSERT  statement. The value of LAST_INSERT_ID()  remains unchanged if no rows are successfully inserted. 

With an argument, LAST_INSERT_ID()  returns an unsigned integer. 

For example, after inserting a row that generates an AUTO_INCREMENT  value, you can get the value like this: 

mysql> SELECT LAST_INSERT_ID(); -> 195 

The currently executing statement does not affect the value of LAST_INSERT_ID() . Suppose that you generate an AUTO_INCREMENT  value with one statement, and then refer to LAST_INSERT_ID()  in a multiple-row INSERT  statement that inserts rows into a table with its own AUTO_INCREMENT  column. The value of LAST_INSERT_ID()  remains stable in the second statement; its value for the second and later rows is not affected by the earlier row insertions. (You should be aware that, if you mix references to LAST_INSERT_ID()  and LAST_INSERT_ID( expr ) , the effect is undefined.) 

If the previous statement returned an error, the value of LAST_INSERT_ID()  is undefined. For transactional tables, if the statement is rolled back due to an error, the value of LAST_INSERT_ID()  is 

