如何在MySQL中模拟print语句?

Rah*_*hul 44 mysql

我有一些程序,我希望在评估条件后得到某种确认.

例如,pusedocode就像,

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

我该如何在MySQL中这样做呢?

小智 55

如果您不希望文本两次作为列标题和值,请使用以下stmt!

__PRE__


Dev*_*oot 23

您可以使用以下SELECT命令打印一些文本:

SELECT 'some text'
Run Code Online (Sandbox Code Playgroud)

结果:

+-----------+
| some text |
+-----------+
| some text |
+-----------+
1 row in set (0.02 sec)
Run Code Online (Sandbox Code Playgroud)

  • 所以不能在mysql中使用print? (3认同)

Guc*_*112 7

这是一篇旧文章,但多亏了这篇文章,我发现了这一点:

\! echo 'some text';
Run Code Online (Sandbox Code Playgroud)

使用 MySQL 8 进行测试并正常工作。很酷吧?:)

  • 非常酷:) 此功能记录在 https://dev.mysql.com/doc/refman/8.0/en/mysql-commands.html 中。 (3认同)