Adam
Adam

Reputation: 4780

MySQL Error 1054: Unknown column in 'field list' on INSERT

I am using MySQL Workbench to create a database. I have a table called USERS defined as follows:

delimiter $$

CREATE TABLE `users` (
  `UID` int(10) unsigned NOT NULL AUTO_INCREMENT 
  `USERNAME` varchar(20) NOT NULL,
  `PASSWORD` varchar(64) NOT NULL
  PRIMARY KEY (`UID`),
  UNIQUE KEY `USER_NAME_UNIQUE` (`USERNAME`),
  KEY `USERS_ROLES_REF_IDX` (`USER_ROLE`),
  CONSTRAINT `USERS_ROLES_REF` FOREIGN KEY (`USER_ROLE`) REFERENCES `roles_ref` (`ROLE_NAME`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8$$

CREATE
DEFINER=`root`@`localhost`
TRIGGER `MyDB`.`users_after_ins_trig`
AFTER INSERT ON `MyDB`.`users`
FOR EACH ROW
begin
    insert into profiles (username) VALUES (new.username);
end
$$

When I go to forward engineer the database and create it, the script gives me the following error. As you can see from above, the username is part of the table. What gives?

Executing SQL script in server

ERROR: Error 1054: Unknown column 'username' in 'field list'

INSERT INTO `MyDB`.`USERS` (`UID`, `USERNAME`, `PASSWORD`) 
VALUES (NULL, 'user1', 'blahpassword')

Upvotes: 0

Views: 20243

Answers (1)

Abe Miessler
Abe Miessler

Reputation: 85096

Could it be that you are inserting into profiles from your trigger? I'm guessing profiles does not have a username column.

Upvotes: 4

Related Questions