To suppress warnings, set SQL_NOTES to 0. Let's look at an example.
First, we will set SQL_NOTES to 1 −
mysql> SET sql_notes = 1; Query OK, 0 rows affected (0.00 sec)
Now, let us delete a table that does not exist. As you can see, a warning message is now visible -
mysql> drop table if exists web.DemoTable; Query OK, 0 rows affected, 1 warning (0.07 sec)
To view the above warning message, you can simply use the SHOW WARNINGS command -
mysql> show warnings;
This will produce the following output, Show warning message −
+-------+------+-----------------------------------+ | Level | Code | Message | +-------+------+-----------------------------------+ | Note | 1051 | Unknown table 'web.DemoTable' | +-------+------+-----------------------------------+ 1 row in set (0.00 sec)
Now, since we need to suppress warnings, use SQL_NOTES and set it to OFF −
mysql> SET sql_notes = 0; Query OK, 0 rows affected (0.00 sec)
Let us abandon the above table again-
mysql> drop table if exists web.DemoTable; Query OK, 0 rows affected (0.07 sec)
The above process is called suppressing warnings in MySQL. Now when you try again to get the warning it will show "empty set" like below -
mysql> show warnings; Empty set (0.00 sec)
The above is the detailed content of How to suppress warnings in MySQL?. For more information, please follow other related articles on the PHP Chinese website!