我在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
当我添加第二个查询时出错:right syntax to use near ''
当我尝试声明变量并使用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
UPDATE2 在之前的更新中错过了分号。 现在工作正常。
答案 0 :(得分:1)
SET @id := 1;
设置正常,但不是
存储过程中的set id=1
应为:=