I have a problem about MySQL, it showed this error message.
Error: ER_DUP_FIELDNAME: Duplicate column name '1'
When I using this code below.
INSERT INTO execution (employee, task, report, accept_time)
SELECT * FROM (SELECT '1', '1', '123', NOW()) AS tmp
WHERE NOT EXISTS (SELECT * FROM execution WHERE employee = '1' AND task = '1') LIMIT 1
I don't know why "(SELECT '1', '1', '123', NOW())" have duplicate problem?
This is original SQL Table.
CREATE TABLE `science_cheer`.`execution` (
`aid` INT NOT NULL AUTO_INCREMENT,
`employee` INT NOT NULL,
`task` INT NOT NULL,
`report` VARCHAR(1000) NOT NULL,
`accept_time` DATETIME NOT NULL,
`audit` VARCHAR(45) NOT NULL DEFAULT 'unaudited',
PRIMARY KEY (`aid`),
INDEX `uid_idx` (`employee` ASC),
INDEX `tid_idx` (`task` ASC),
CONSTRAINT `employee`
FOREIGN KEY (`employee`)
REFERENCES `science_cheer`.`user` (`uid`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `task`
FOREIGN KEY (`task`)
REFERENCES `science_cheer`.`task` (`tid`)
ON DELETE NO ACTION
ON UPDATE NO ACTION);