mysqlmysql-error-1054

error 1054. Unknown coloumn in Insert clause


I have this problem: If I write the following query:

INSERT INTO prodotto  (Barcode, InseritoDa,  DataInserimento, UrlImage) 
VALUES  ('vfr','ff','12-10-2012', 'vfr.jpg')    

I get this error message:

Error Code: 1054. Unknown column 'InseritoDa' in 'where clause'

But in the table prodotto i have this column and its name InseritoDa.

Where am I wrong? the error may be due to the fact that the field InseritoDa is a foreign key that points to another table called utente?

the trigger associated to the table is:

-- Trigger DDL Statements
DELIMITER $$

USE `m4af`$$

CREATE
DEFINER=`root`@`localhost`
TRIGGER `m4af`.`IncrementaProdottiInseritiUtente`
AFTER INSERT ON `m4af`.`prodotto`
FOR EACH ROW
update utente as u
set ProdottiInseriti= (select ProdottiInseriti from utente where username= InseritoDa)+1
where u.username = InseritoDa$$

Solution

  • Since the error states that it occurred in a WHERE clause there might be an insert-trigger that executes another query and fails. There is no WHERE clause in your insert statement.

    Edit

    Try to edit your INSERT trigger like this:

    update utente
    set ProdottiInseriti = ProdottiInseriti + 1
    where username = NEW.InseritoDa