How can I simulate a print statement in MySQL?


To simulate a print statement in MySQL, you can use select statement. The syntax is as follows −

SELECT ‘anyStringValue’ as ’ ‘;

You can check the above syntax at the MySQL command line client.

Case 1

To print a string.

mysql> select 'HELLO MYSQL' as ' ';

Output

+-------------+
|             |
+-------------+
| HELLO MYSQL |
+-------------+
1 row in set (0.00 sec)


Case 2

a) To print integer, use the following query −

mysql> select 23 as ' ';

Output

+----+
|    |
+----+
| 23 |
+----+
1 row in set (0.00 sec)

b) To print float or double type, use the following query −

mysql> select 23.45 as ' ';

Output

+-------+
|       |
+-------+
| 23.45 |
+-------+
1 row in set (0.00 sec)

Updated on: 29-Jun-2020

7K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements