How can I simulate a print statement in MySQL?

后端 未结 4 1480
忘掉有多难
忘掉有多难 2020-12-08 06:02

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,

相关标签:
4条回答
  • 2020-12-08 06:44

    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? :)

    0 讨论(0)
  • 2020-12-08 06:53

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

    SELECT 'some text'
    

    Result:

    +-----------+
    | some text |
    +-----------+
    | some text |
    +-----------+
    1 row in set (0.02 sec)
    
    0 讨论(0)
  • 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)

    0 讨论(0)
  • 2020-12-08 07:05

    to take output in MySQL you can use if statement SYNTAX:

    if(condition,if_true,if_false)
    

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

    0 讨论(0)
提交回复
热议问题