gpt4 book ai didi

mysql - select into变量或者在shell脚本中实现mysql的select里面的select

转载 作者:行者123 更新时间:2023-11-29 00:08:04 25 4
gpt4 key购买 nike

我在 shell 中有这样的 mysql 脚本:

#!/bin/bash
keyOrPass=$1
intercom=$2
flat=$3
number=$4
mysql -ulogin -ppassword db_name << EOF
select codeGuestEmail, codePrivateEmail from mbus_clients WHERE flat=$flat and domophone=$intercom;
select * from mbusClientKeys where id_client=(select id from mbus_clients WHERE flat=${flat} and domophone=${intercom});
EOF

当我添加第二个查询时出现错误:在 '' 附近使用正确的语法 当我尝试声明变量并使用 select into 时,因为它在存储过程中,这也不起作用。来自 previous question 的 EOF 也有误是实际的。
更新我的尝试也不起作用:

SET @id := 1;
select id into @id from mbus_clients WHERE flat=${flat} and domophone=${intercom};

right syntax to use near 'select id into @id from mbus_clients WHERE flat=200

更新2上一次更新中遗漏了分号。现在工作正常。

最佳答案

SET @id := 1;

设置工作正常,但不是set id=1 因为它在存储过程中应该是 :=

关于mysql - select into变量或者在shell脚本中实现mysql的select里面的select,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26585551/

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