Jump to content

[SOLVED] INSERT INTO QUERY


Kathy

Recommended Posts

I'm trying to insert multiple values into one field in my table using the following statement:

INSERT INTO table name (field)
        VALUES ('type','type','type',type')

I'm getting the following error if I do this though:

#1136 - Column count doesn't match value count at row 1

Can anybody give me some advice?

Link to comment
https://forums.phpfreaks.com/topic/165781-solved-insert-into-query/
Share on other sites

Hi

 

Depends on the layout of the table categories.

 

My guess is that there is another column in the table set as the primary key but not set as an autoincrement.

 

ie, you have something like :-

 

CREATE TABLE `categories` (
  `Id` int(11) NOT NULL,
  `Category` varchar(50) NOT NULL,
  PRIMARY KEY  (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

 

and need something like:-

 

CREATE TABLE `categories` (
  `Id` int(11) NOT NULL auto_increment,
  `Category` varchar(50) NOT NULL,
  PRIMARY KEY  (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

 

All the best

 

Keith

Just tried the following:

INSERT INTO categories (Category) VALUES (‘Chemicals & Refining Agents’),(‘CIP Systems’),(‘Cleaning’),(‘Equipment & Services’)

I get the following error:

#1064 - 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 'Agents’),(‘CIP Systems’),(‘Cleaning’),(‘Equipment & Services’)' at line 1

why is this?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.