Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8202441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T07:11:07+00:00 2026-06-07T07:11:07+00:00

I have a unique index on a column named label , but for some

  • 0

I have a unique index on a column named label, but for some strange reason why I try and do an update like:

UPDATE books SET label = 'foo bar', title = 'something new', modified = UTC_TIMESTAMP();

And there already exists a row with label = ‘foo bar’ this errors:

 #1062 - Duplicate entry 'foo bar' for key 'label'

How can I make MySQL do the update? This shouldn’t be breaking because technically there is still just one row with the key foo bar.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T07:11:09+00:00Added an answer on June 7, 2026 at 7:11 am

    This SQL query is trying to update every single record in the books table with those values, because you have no WHERE clause. Its failing because you can only have one record with that label value yet the query wants to set them all to it.

    I think possibly you are not executing the query you intended. Maybe you meant to update the title and time for the record with that label. Check your syntax.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have SQL Server 2008 R2 and I want to set a unique column.
I have an SQL database with a set of tables that have Unique Id's.
I know that using the following codes will make each column have unique values,
I have a unique set-up I am trying to determine if Heroku can accommodate.
I have a table 'users' with 'login' column defined as: [login] VARCHAR(50) UNIQUE NOT
I've read about 20 topics about index performance, but still have several questions... Would
Do index names have to be unique accross the entire sql server database, or
I am trying to add a spatial index to a table column named Location
I have very strange problem with mySQL and simple query with simple index. I
I often have to check a table column before performing an update, insert, or

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.