0

I want to insert a tuple of data into mysql.

I did

INSERT INTO goods_table (name,kind,price,discount, store ,detail)
            VALUES("abc","A",3960,10,100,'adf');

the definition of table:

CREATE TABLE `goods_table` (
  `id` int(4) AUTO_INCREMENT NOT NULL ,
  `name` varchar(45) NOT NULL,
  `kind` varchar(20) NOT NULL,
  `price` int(11) NOT NULL,
  `discount` int(11) DEFAULT NULL,
  `store` int(11) NOT NULL,
  `detail` varchar(100) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

I have checked the mysql mannual for insert statement

INSERT INTO tbl_name (a,b,c) VALUES(1,2,3),(4,5,6),(7,8,9);

I don't know why mysql always report the same error many many times!

    ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
         that corresponds to your MySQL server version for the right syntax to use near 
        '("abc","A",3960,10,100,'adf')' at line 1

this is a very simple operation.. I have checked very character of my statement to official example. and I have been stuck at this simple statement for a whole afternoon, which is unbelievable.

update: I try to change the way of quotes

insert into `goods_table` (`name`,`kind`,`price`,`discount`,`store`)
values ('abc','A',3960,10,100);

it make no changes to the error

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')
values ('abc','A',3960,10,100)' at line 1

many people say this is caused by using double quotes, but it is exactly not. I follow the answer and execute

INSERT INTO goods_table (name,kind,price,discount, store ,detail)VALUES("abc","A",3960,10,100,"adf");

I use double quotes, it did

2 Answers2

1

You use

which is a special character.

Use this instead:

) 

Complete query:

insert into `goods_table` (`name`,`kind`,`price`,`discount`,`store`) values ('abc','A',3960,10,100);
                                                                   ^------ here
juergen d
  • 201,996
  • 37
  • 293
  • 362
-1

INSERT INTO tableName( name, kind, price, discount, store, detail`) VALUES ('abc','A',3960,10,100,'adf');

use '' sinqle quotes for varchar values do not include primary key if it auto generated

Community
  • 1
  • 1