Jump to content

Unable to insert multiple records to a row


osherdo
Go to solution Solved by osherdo,

Recommended Posts

I am trying to insert multiple rows to a column in mysql like this:

INSERT INTO `sportsapp`.`exercises` (`id`, `image_path`, `name`, `category`) VALUES ('3', 'exercises/biceps/barbell_curls_lying_against_an_incline.jpg', 'Barbell Curls Lying Against An Incline', 'Biceps'),
('4','exercises/biceps/cable_hammer_curls_-_rope_attachment','Cable hammer Curls - Rope Attachment','Biceps');

I am getting an error in return:

 

 

#1062 - Duplicate entry '3' for key 'PRIMARY'

 

I tried to google and understand what's the reason for it, but I dont get it. I do have already a primary key, and I don't know why it generates another primary key,

 

Could you please try to help with this?

Link to comment
Share on other sites

Is the "id" column set to auto increment? If so, you could leave it out of the query.

INSERT INTO `sportsapp`.`exercises` (`image_path`, `name`, `category`) VALUES 
('exercises/biceps/barbell_curls_lying_against_an_incline.jpg', 'Barbell Curls Lying Against An Incline', 'Biceps'), 
('exercises/biceps/cable_hammer_curls_-_rope_attachment', 'Cable hammer Curls - Rope Attachment', 'Biceps');
Link to comment
Share on other sites

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.