SHOW WARNINGS
SHOW WARNINGS [LIMIT [offset,]count] SHOW COUNT(*) WARNINGS
Use this statement to display warning messages, error
messages, and notes for previous SQL statements for the current
session. This statement is available as of version 4.1 of MySQL. To
find out the number of such messages generated by the previous
statement in the session, use COUNT(*). Use the
LIMIT clause to limit the number of messages
displayed. An offset can be given along with the limit to specify a
starting point for displaying messages. Here are a couple of examples
of how you can use this statement:
INSERT INTO clients (client_name, telephone)
VALUES('Marie & Associates', '504-486-1234');
Query OK, 1 row affected, 1 warning (0.00 sec)
SHOW COUNT(*) WARNINGS;
+-------------------------+
| @@session.warning_count |
+-------------------------+
| 1 |
+-------------------------+
SHOW WARNINGS;
+---------+------+--------------------------------------------------+
| Level | Code | Message |
+---------+------+--------------------------------------------------+
| Warning | 1265 | Data truncated for column 'client_name' at row 1 |
+---------+------+--------------------------------------------------+In this example, we enter the name of a client and her telephone
number in the table clients, but in the results we
see that one warning is issued. The second statement returns the
number of messages; of course, the last line of the results from the
INSERT already told us this. Notice that the
results are stored in the session variable warning_count. The third SQL statement
displays the warning message. These statements are perhaps more
meaningful when used with an API program in which you would like to
capture the number of errors generated or the error messages for a
specific purpose or analysis.