SHOW ERRORS
SHOW ERRORS [LIMIT [offset,]count] SHOW COUNT(*) ERRORS
Use this statement to display error messages. The results
are only for the previous statement that has been executed. To see the
number of error messages generated by an SQL statement, use
COUNT(*). To limit the number of error messages
displayed, use the LIMIT clause. An offset can be
given along with the count to specify a starting point for displaying
error messages.
This statement is available as of version 4.1 of MySQL. It will
not display warnings or notes—just error messages. Use SHOW
WARNINGS to get all three types of messages.
Here are a couple of examples of this statement, which were
entered after an INSERT statement was entered and
encountered a problem:
SHOW COUNT(*) ERRORS; +-----------------------+ | @@session.error_count | +-----------------------+ | 1 | +-----------------------+ SHOW ERRORS; +-------+------+-------------------------------------------------+ | Level | Code | Message | +-------+------+-------------------------------------------------+ | Error | 1136 | Column count doesn't match value count at row 2 | +-------+------+-------------------------------------------------+
The first statement returns the number of error messages
generated by the INSERT statement. Notice that the
results are stored in the session variable
error_count, which is updated by each statement
issued in the session. The second statement displays the error
messages. This statement is perhaps more meaningful when used with an
API program in which you would like to capture the error messages for
a specific purpose or analysis.