How can I simulate a print statement in MySQL?

MySQLMySQLi Database

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)
raja
Updated on 29-Jun-2020 08:11:52

Advertisements