Jump to content

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?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.