How to echo print statements while executing an SQL script?


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)

Updated on: 30-Jul-2019

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements