gpt4 book ai didi

mysql - 错误代码: 1241. Workbench, MySQL, cannot resolve the parameters

转载 作者:行者123 更新时间:2023-12-03 07:42:44 26 4
gpt4 key购买 nike

我正在使用Workbench编写查询。
成功创建了以下过程(没有问题)。
但是当尝试执行功能时,出现此错误:
错误代码:1241。操作数应包含1列
如果有人帮助我,我将非常感激。

delimiter $$
create procedure usp_raise_salaries1(department_name varchar(30))
begin

update employees as e
set salary = salary * 1.05
where (select first_name, salary from employees as e
join departments as d on e.department_id = d.department_id
where d.name = department_name);


end $$

delimiter ;

set @answer = 'Sales';
call usp_raise_salaries(@answer); -- The Workbench gives error at this line.

最佳答案

您从子查询中获得了很多行,因此需要'IN子句来选择要更新的行

delimiter $$
create procedure usp_raise_salaries1(department_name varchar(30))
begin

update employees as e
set salary = salary * 1.05
where (first_name, salary) IN (select first_name, salary from employees as e
join departments as d on e.department_id = d.department_id
where d.name = department_name);


end $$

delimiter ;

关于mysql - 错误代码: 1241. Workbench, MySQL, cannot resolve the parameters,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64283420/

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