How do I show a MySQL warning that just happened?


To show a MySQL warning, you can use the below syntax −

SHOW WARNINGS;

The above syntax only displays the immediate warning from MySQL prompt. Suppose you run another query between them or you have lost the MySQL connection, then SHOW WARNINGS will not work.

Here is the query to display warnings −

mysql> SHOW WARNINGS;

Here is the output that displays immediate warning −

+-------+------+---------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Level | Code | Message                                                                                                                                                       |
+-------+------+---------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Error | 1064 | You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'QUERY CACHE' at line 1 |
+-------+------+---------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

Updated on: 30-Jul-2019

265 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements