MySQueaL Resources

resources for mysql admins and developers who are squealing for help

More Resources

Main Doc Pages
Related Documentation
Comments
MySQL columns: everywhere I look are tables and columns; life is filled with databases of information to be ordered and grouped. (Berlin, Germany)

SHOW ERRORS Statement

Use this MySQL statement to display error messages for the previous SQL statement. It has a COUNT(*) clause that you can use to see the number of error messages generated rather than displaying them.

hits past month: 6 ;  last updated: may 4, 2009 - 2:34am ;  parent: Data Manipulation Statements

Syntax

SHOW ERRORS [LIMIT [offset,] count]

SHOW COUNT(*) ERRORS

Explanation

Use this statement to display error messages for the previous SQL statement. To see the number of error messages generated by the previous SQL statement, use the COUNT(*) clause. 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 the MySQL statement, SHOW WARNINGS to get all three types of messages.

Examples

Here are a couple of examples of this MySQL 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 MySQL 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.

Return to Data Manipulation Statements page of our MySQL Documentation