How to echo print statements while executing an SQL script?

MySQLMySQLi Database

To perform echo print statements while executing SQL scripts, use the following syntax.

The syntax is as follows −

SELECT ‘anyStringValue as’ ‘;

The query is as follows −

mysql> select 'This is a SQL Script' AS' ';

The following is the output −

+----------------------+
|                      |
+----------------------+
| This is a SQL Script |
+----------------------+
1 row in set, 1 warning (0.00 sec)

You can add dynamic data to your status like insert, update and delete with the help of concat() function. The query is as follows −

mysql> select concat ("Inserted ", row_count(), " rows successfully") AS '';

The following is the output −

+-------------------------------+
|                               |
+-------------------------------+
| Inserted -1 rows successfully |
+-------------------------------+
1 row in set (0.00 sec)
raja
Published on 16-Jan-2019 10:03:35
Advertisements