How can I simulate a print statement in MySQL?

I have some procedures where I would like to get some kind of acknowledgement after a condition has been assessed.

For example, the pusedocode would be like,

if ( select count(*) from assgn to where eid = 1 )  > 5
  print " the total number of projects employee working is more than 5 "
  insert the value into the assgnto table

How should I go about doing that in MySQL?


Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

If you do not want to the text twice as column heading as well as value, use the following stmt!

SELECT ‘some text’ as ”;

Example: mysql>SELECT ‘some text’ as ”;
| |
| some text |
1 row in set (0.00 sec)

Method 2

You can print some text by using SELECT command like that:

SELECT 'some text'


| some text |
| some text |
1 row in set (0.02 sec)

Method 3

This is an old post, but thanks to this post I have found this:

! echo 'some text';

Tested with MySQL 8 and working correctly. Cool right? 🙂

Method 4

to take output in MySQL you can use if statement


the if_true and if_false can be used to verify and to show output
as there is no print statement in the MySQL

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x