0

Trying to do an insert in MySQL and getting an error that I cannot figure out. The syntax (at least from my perspective) is right. I've tried tinkering around with a lot of little things and cannot figure it out. Also tried dropping and recreating the table and it still happens.

Insert Code:

 insert into `apType` (`type`) values (`private`),(`public`),(`military`);

table creation code:

 CREATE TABLE `apType`(
`id` int primary key AUTO_INCREMENT,
`type` varchar(255) NOT NULL
 )ENGINE=MyISAM DEFAULT CHARSET=latin1;

error code generated:

1054 - Unknown column 'private' in 'field list'

4

1 回答 1

1

这是一个正确的 SQL - 注意插入值的单引号:

INSERT INTO `apType` (`type`) VALUES ('private'),('public'),('military');

您的 SQL 实际上在做的是尝试从私有、公共和军事字段中插入值——实际上这些字段并不存在。

于 2013-07-28T20:47:12.683 回答