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 1110055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:20:07+00:00 2026-05-17T02:20:07+00:00

I have a table with year column and this column shouldn’t have duplicate values.

  • 0

I have a table with year column and this column shouldn’t have duplicate values. So I end up with a table with only one 2007 year record for example.

So how could I delete those rows that have duplicate year value?

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-05-17T02:20:08+00:00Added an answer on May 17, 2026 at 2:20 am

    I think you could simply try adding a UNIQUE INDEX using IGNORE:

    ALTER IGNORE TABLE `table` ADD UNIQUE INDEX `name` (`column`);
    

    MySQL should respond with something like:

    Query OK, 4524 rows affected (1.09 sec)
    Records: 4524 Duplicates: 9342 Warnings: 0
    

    Of course, you’ll leave it up to MySQL to decide which rows to drop.

    EDIT:

    this works for as many columns as you like:

    ALTER IGNORE TABLE `table` ADD UNIQUE INDEX `name` (`col1`, `col2`, `col3`);
    

    check MySQL’s documentation on CREATE INDEX. A common gotcha (at least one I ran into once) is to forget that NULL = NULL isn’t true (but NULL), hence {42, NULL} and {42, NULL} are allowed for a UNIQUE index on two columns.

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

Sidebar

Related Questions

Possible Duplicate: Derived/calculated column on existing table I have SQL Server table with values,
i have day, month, year, value columns in one table, here i need to
I have a table that looks like this: Name Job Year ImpFile ImpDate ------------------------------------------------
I have a table that looks something like this: Name Year Value A 2000
I have one table, t1, which has fileds called userid, week and year fields.
I have table like this: CREATE TABLE Date_Table (Year DATETIME , Month1 INTEGER, Month2
I have a table with a column called YEAR. I would like to create
Below I have table - Company id name value year 1 IBM 10 2011
I have a table like: id number year I want to find holes, or
I have a table in MySQL 4.0 which currently has a year field as

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.