Can I use two insert into the same command

-1

I have the following line of code and wanted to know if it is possible to do two select within a single sql command

cmd = new MySqlCommand("insert into FUNCIONARIO('CPF_FUNCIONARIO', 'NOME_FUNCIONARIO', 'RG_FUNCIONARIO ', 'ENDEREÇO_FUNCIONARIO', 'NUMERO_FUNCIONARIO', 'BAIRRO_FUNCIONARIO', 'CEP_FUNCIONARIO', 'CIDADE_FUNCIONARIO', 'ADMISSÃO_FUNCIONARIO', 'DEMISSÃO_FUNCIONARIO', 'ID_CARGO', 'AUMENTO_FUNCIONARIO') values(@CPF,@NOME,@RG,@ENDERECO,@NUMERO,@BAIRRO,@CEP,@CIDADE,@CARGO,@AUMENTO)  INSERT INTO 'LOGIN'('USUARIO_LOGIN', 'SENHA_LOGIN', 'CPF_FUNCIONARIO') VALUES (@LOGIN,@SENHA,@CPF)", con);
    
asked by anonymous 25.10.2018 / 05:09

1 answer

2

Yes you can, I even do that a lot. in addition to separating the values with "," you have to have exactly the same amount of parameters of all the sequences of values, eg:

insert into my_table (coluna1, coluna2,coluna3) 
            values   (@0,@1,@2),(@3,@4,@5),(@6,@7,@8)...;

If in some sequence of values you put two or a parameter will give error, it has to be always 3 parameters because I defined 3 columns.

    
25.10.2018 / 05:45