gpt4 book ai didi

mysql - 如何在 MySQL 的命令行中显示变量的值?

转载 作者:IT老高 更新时间:2023-10-28 12:58:47 25 4
gpt4 key购买 nike

我尝试了以下 -

我在命令提示符下创建了一个变量如下 -

mysql> set @myId = 1;
Query OK, 0 rows affected (0.00 sec)

然后,为了显示它,我尝试了以下但没有成功 -

    mysql> show myId;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'myId' at line 1
mysql> show @myId;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near '@myId' at line 1
mysql> PRINT @myId;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'PRINT @myId' at line 1
mysql> PRINT myId;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'PRINT myId' at line 1

那么如何显示 @myId 的值呢?

最佳答案

只需 SELECT 像这样的变量:

SELECT @myId;

这是关于用户定义变量的 MySQL 文档:

http://dev.mysql.com/doc/refman/5.5/en/user-variables.html

关于mysql - 如何在 MySQL 的命令行中显示变量的值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18838611/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com