error 1054. Unknown coloumn in Insert clause

2019-07-17 06:42发布

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 coloumn and its named 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$$

1条回答
小情绪 Triste *
2楼-- · 2019-07-17 07:07

Since the error states that it occured 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
查看更多
登录 后发表回答