简体   繁体   English

错误代码 1241 - 操作数应包含 1 列

[英]Error Code 1241 - Operand should contain 1 column(s)

I was creating a procedure and I came across this.我正在创建一个程序,我遇到了这个。 Does anyone know how to solve this?有谁知道如何解决这个问题?

delimiter $$
create procedure sp_cadastraAluno(
in nome varchar(150),
in chamada varchar(3),
in data date, 
in ra varchar(12),
in turma varchar(50),
in cpf varchar(14))
begin
    declare x int;
    set x = (select * from tb_coordenador inner join tb_professor
    on tb_coordenador.cd_coord = tb_professor.cd_coord
    inner join prof_turma on
    tb_professor.cd_prof = prof_turma.cd_prof
    inner join tb_turma on
    prof_turma.cd_turma = tb_turma.cd_turma 
    inner join tb_aluno on
    tb_turma.cd_turma = tb_aluno.cd_turma where nm_turma = turma and tb_professor.cd_cpf = cpf);

    insert into tb_aluno(nm_aluno, cd_chamada, dt_nascimento, cd_ra, cd_turma) values
    (nome, chamada, data, ra, x);
end $$

I need to insert in tb_aluno and for this, I need to pull the code already inserted in tb_turma , but this error appears.我需要插入tb_aluno ,为此,我需要提取已经插入tb_turma的代码,但出现此错误。

You can't set variable 'x' with multiple columns.您不能使用多列设置变量“x”。 try removing select * and replace with the column which you need.尝试删除 select * 并替换为您需要的列。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM