簡體   English   中英

如何在 MySQL 中模擬打印語句?

[英]How can I simulate a print statement in MySQL?

我有一些程序,我希望在評估條件后得到某種確認。

例如,pusdocode 會是這樣的,

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  

我應該如何在 MySQL 中做到這一點?

如果您不想將文本兩次作為列標題和值,請使用以下 stmt!

SELECT 'some text' as '';

Example:

mysql>SELECT 'some text' as ''; +-----------+ | | +-----------+ | some text | +-----------+ 1 row in set (0.00 sec)

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

SELECT 'some text'

結果:

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

這是一篇舊帖子,但多虧了這篇文章,我才發現:

\! echo 'some text';

使用 MySQL 8 測試並正常工作。 酷吧? :)

要在 MySQL 中獲取輸出,您可以使用 if 語句 SYNTAX:

if(condition,if_true,if_false)

if_true 和 if_false 可用於驗證和顯示輸出,因為 MySQL 中沒有打印語句

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM