错误代码:1241。Workbench、MySQL,无法解析参数
Error Code: 1241. Workbench, MySQL, cannot resolve the parameters
我正在使用 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 子句来 select 要更新的行
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 ;
我正在使用 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 子句来 select 要更新的行
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 ;