错误代码:1136.列计数与第 1 行的值计数不匹配(我知道这是什么意思) [英] Error Code: 1136. Column count doesn't match value count at row 1 (I know what does it mean)

查看:84
本文介绍了错误代码:1136.列计数与第 1 行的值计数不匹配(我知道这是什么意思)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个在 MYSQL 中使用此代码的存储过程:

I am creating a stored procedure that uses this code in MYSQL:

DECLARE id_historico_adscripciones_personal int;

SET @id_historico_adscripciones_personal = (select max(id) from historico_adscripciones_personal)+1;

INSERT INTO historico_adscripciones_personal(id,id_empleado,id_estatus_historico,id_estatus,id_rme_o_dep,sueldo,moneda,observaciones,fecha_creacion,fecha_actualizacion values(@id_historico_adscripciones_personal,@id_empleado_o,@id_estatus_historico_o,5,@id_rme_o_dep,@sueldo_o,@moneda_o,@observaciones_o,now(),now());

我从 MYSQL 收到以下错误:

I get the following error from MYSQL:

Error Code: 1136. Column count doesn't match value count at row 1

我知道这意味着什么,这里的主题是,如果在上面的代码中,我在单词值 @id_historico_adscripciones_personal 后面更改了一个数字(即:71)

I know what that means, the topic here is that if in the code above I change after the word values @id_historico_adscripciones_personal by a number (i.e: 71)

 INSERT INTO historico_adscripciones_personal(id,id_empleado,id_estatus_historico,id_estatus,id_rme_o_dep,sueldo,moneda,observaciones,fecha_creacion,fecha_actualizacion) values(71,@id_empleado_o,@id_estatus_historico_o,5,@id_rme_o_dep,@sueldo_o,@moneda_o,@observaciones_o,now(),now());

我没有收到错误消息.我已经测试了 SET 过程,一切似乎都没有问题.

I dont get the error message. I've already tested the SET procedure and everything seems to be OK.

推荐答案

您似乎忘记在 INSERT 中关闭括号.

It seems that you forgot close a parenthesis in the INSERT.

INSERT INTO historico_adscripciones_persona (
    id,
    id_empleado,
    id_estatus_historico,
    id_estatus,
    id_rme_o_dep,
    sueldo,
    moneda,
    observaciones,
    fecha_creacion,
--  fecha_actualizacion  <-- ")"
    fecha_actualizacion)
VALUES (
    @id_historico_adscripciones_personal,
    @id_empleado_o,
    @id_estatus_historico_o,
    5,
    @id_rme_o_dep,
    @sueldo_o,
    @moneda_o,
    @observaciones_o,
    now(),
    now()
);

一些注意事项:

  • @id_historico_adscripciones_personal is a 9.4. User-Defined Variables and id_historico_adscripciones_personal one 13.6.4.1. Local Variable DECLARE Syntax, are different variables.
  • For the next id of your tables avoid using MAX. Try using 3.6.9 Using AUTO_INCREMENT.

这篇关于错误代码:1136.列计数与第 1 行的值计数不匹配(我知道这是什么意思)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆