【问题标题】:error 1054. Unknown coloumn in Insert clause错误 1054。插入子句中的未知列
【发布时间】:2012-10-03 10:43:41
【问题描述】:

我有这个问题: 如果我编写以下查询:

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

我收到此错误消息:

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

但在prodotto 表中,我有此列及其名称 InseritoDa。

我哪里错了? 该错误可能是由于字段InseritoDa 是指向另一个名为utente 的表的外键?

与表关联的触发器是:

-- 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$$

【问题讨论】:

  • 你在那个表上定义了触发器吗?
  • 您是否检查过该列的准确拼写和大写/小写?也许张贴一张截图或该表的CREATE TABLE 命令。

标签: mysql mysql-error-1054


【解决方案1】:

由于错误表明它发生在 WHERE 子句中,因此可能存在执行另一个查询并失败的插入触发器。您的插入语句中没有 WHERE 子句。

编辑

尝试像这样编辑您的 INSERT 触发器:

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

【讨论】:

  • 请出示您的触发语句。很可能有一个错误。
  • 在您的触发器中,您使用表 utente 中名为 InseritoDa 的列。那张表有这样的列吗?
  • 不,InseritoDa 列仅在表 prodotto 中,但在插入该表后调用触发器,所以我想使用它。那么,如何更改触发器?
  • 你想在触发器中做什么?我不确定你想要达到什么目标。
  • 每次在表prodotto插入产品时,我想在表中增加字段prodottiInseriti 在字段inseritoDa的基础上。
猜你喜欢
  • 2015-09-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-06-11
  • 2011-03-22
  • 2016-03-19
  • 1970-01-01
  • 2016-10-13
相关资源
最近更新 更多