I do not understand why I get this error 1136?

1
  

Operation failed: There was an error while applying the SQL script to the database.

Executing:
INSERT INTO 'bdaeropuerto'.'tb_hangars' 
    ('Clave', 'Aeropuerto', 'Capacidad', 'Tipo', 
    'Aerolinea', 'Estatus', 'Aeropuertos_Id', 'Aviones_Id', 'Empleados_Id')
 VALUES ('fdbgdf', 'dbdvd', '12', 'bkh', 'kbkb', 'kbkb', '1', '1', '2');
  

ERROR 1136: 1136: Column count does not match value count at row 1

SQL Statement:
INSERT INTO 'bdaeropuerto'.'tb_hangars' 
    ('Clave', 'Aeropuerto', 'Capacidad', 'Tipo', 
    'Aerolinea', 'Estatus', 'Aeropuertos_Id', 'Aviones_Id', 'Empleados_Id') 
VALUES ('fdbgdf', 'dbdvd', '12', 'bkh', 'kbkb', 'kbkb', '1', '1', '2')

That's the Trigger

DELIMITER @ 
CREATE TRIGGER triggerInsertar before INSERT ON tb_hangars 
  FOR EACH ROW 
    BEGIN 
     INSERT INTO bitacora_hangares 
       values(
         new.Clave, new.Capacidad, new.Tipo,
         new.Aerolinea, new.Estatus,
         new.Aeropuertos_Id, new.Aviones_Id,
         new.Empleados_Id, curdate(), 'Agregado'
       );
    END;
@ DELIMITER ;
    
asked by Pato Hernandez 08.04.2017 в 21:17
source

1 answer

1

The id or key as you named the first field is surely an autoincrementable value, it is assumed that you try to insert a new field by not updating it.

You have to omit the field that is defined as incremental in the structure of your table.

Example, if in my table I have defined Id as incretable and I add it to my script for insertion I will get the error you mention:

INSERT INTO  'myDatabase'.'Usuarios' ('Id' , 'Name' , 'Message')
VALUES (1,  'Elenasys',  'Working on Python');

The correct thing would be to omit the incremental field:

INSERT INTO  'myDatabase'.'Usuarios' ('Name' , 'Message')
VALUES ('Elenasys',  'Working on Python');

This error can also occur if you have a Trigger in the table you wish to insert and that trigger has another insertion instruction without matching columns and values, it also causes the error:

  

"Column count does not match value count at row".

    
answered by 08.04.2017 в 21:45