title: MySQL AFTER INSERT Trigger "Unknown Column"
body: <p>I have researched the issue and it usually relates to the column names not matching up. I've checked and re-checked my column names to make sure they match up. I can't figure out why it's complaining. Maybe all I need is a 2nd pair of eyes, or a long lunch-break?</p>
  
  <p><strong>Tables:</strong></p>
  
  <pre><code>DROP TABLE IF EXISTS `User`;
  CREATE TABLE `User` (
    `ID` int(11) NOT NULL AUTO_INCREMENT,
    `userType` varchar(20) NOT NULL,
    `firstName` varchar(20) NOT NULL,
    `lastName` varchar(40) NOT NULL,
    `email` varchar(40) DEFAULT NULL,
    `contributorRating` int(1) DEFAULT NULL,
    `dateCreated` timestamp DEFAULT CURRENT_TIMESTAMP,
    `isFlagged` bit(1) DEFAULT NULL,
    PRIMARY KEY (`ID`),
    KEY `userType` (`userType`),
    CONSTRAINT `User_ibfk_1` FOREIGN KEY (`userType`) REFERENCES `UserType` (`userType`)  ON UPDATE CASCADE
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  DROP TABLE IF EXISTS `User_Project`;
  CREATE TABLE `User_Project` (
    `projectID` int(11) NOT NULL,
    `userID` int(11) NOT NULL,
    `joinDate` timestamp DEFAULT CURRENT_TIMESTAMP,
    PRIMARY KEY (`projectID`,`userID`),
    KEY `userID` (`userID`),
    CONSTRAINT `User_Project_ibfk_1` FOREIGN KEY (`projectID`) REFERENCES `Project` (`ID`) ON UPDATE CASCADE,
    CONSTRAINT `User_Project_ibfk_2` FOREIGN KEY (`userID`) REFERENCES `User` (`ID`) ON UPDATE CASCADE
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  DROP TABLE IF EXISTS `Project`;
  CREATE TABLE `Project` (
    `ID` int(11) NOT NULL AUTO_INCREMENT,
    `userID` int(11) NOT NULL,
    `projectName` varchar(40) NOT NULL,
    `frequencyType` varchar(10) DEFAULT NULL,
    `projectType` varchar(20) NOT NULL,
    `projectDescription` text NOT NULL,
    `dateCreated` timestamp DEFAULT CURRENT_TIMESTAMP,
    `startDate` timestamp DEFAULT 0,
    `endDate` timestamp DEFAULT 0,
    `isActive` tinyint(1) unsigned NOT NULL,
    `visibility` varchar(20) DEFAULT 'private',
    `region` varchar(20) NOT NULL,
    `isFlagged` bit(1) DEFAULT NULL,
    `lastUpdate` timestamp DEFAULT 0,
    PRIMARY KEY (`ID`),
    KEY `userID` (`userID`),
    KEY `frequencyType` (`frequencyType`),
    KEY `projectType` (`projectType`),
    CONSTRAINT `Project_ibfk_1` FOREIGN KEY (`userID`) REFERENCES `User` (`ID`) ON UPDATE CASCADE,
    CONSTRAINT `Project_ibfk_2` FOREIGN KEY (`frequencyType`) REFERENCES `Frequency` (`frequency`) ON UPDATE CASCADE,
    CONSTRAINT `Project_ibfk_3` FOREIGN KEY (`projectType`) REFERENCES `ProjectType` (`projectType`) ON UPDATE CASCADE,
    CONSTRAINT `Project_ibfk_4` FOREIGN KEY (`visibility`) REFERENCES `Visibility` (`visibility`) ON UPDATE CASCADE
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  </code></pre>
  
  <p><strong>Trigger:</strong></p>
  
  <pre><code> DROP TRIGGER IF EXISTS ins_Project;
   CREATE TRIGGER ins_Project AFTER INSERT ON `Project`
   FOR EACH ROW 
   BEGIN
    SET NEW.lastUpdate = NOW();
    INSERT IGNORE INTO User_Project(projectID,userID,joinDate) VALUES (NEW.ID,NEW.userID,NOW());
   END;
  </code></pre>
  
  <p><strong>Error:</strong></p>
  
  <pre><code>ERROR 1054 (42S22): Unknown column 'NEW.ID' in 'field list'
  </code></pre>