How do I show a MySQL warning that just happened?

MySQLMySQLi Database

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)
raja
Published on 21-Dec-2018 12:40:36
Advertisements