-2

i am having a mysql table named list which contains only one column named word. In this name column i am having english words. There are around 1 lakh records. I formed these column by joining different tables.

Now the problem is i am having some duplicate words and i need to delete it.

I tried

insert into new_table select distinct word from list;

contents are being copied to another table but still the duplicate exits

Then i tried to print length of the word using php.. 'aardvark' is present two times in my table. printing the length of this word in php, for one record it is showing that length is 8 and for another record of 'aardvark' is of length 9.

i used

update list set word = trim(word);

no word contained blank spaces in front or end.. How the same word 'aardvark' is of two different length. how to avoid duplicates

Madara's Ghost
  • 172,118
  • 50
  • 264
  • 308
srinath
  • 2,748
  • 6
  • 35
  • 56
  • 2
    Please browse the **Related** section at the bottom right of this page. This question was asked many many times. – Madara's Ghost Jul 29 '12 at 19:43
  • possible duplicate of [how to delete duplicates on mysql table?](http://stackoverflow.com/questions/2630440/how-to-delete-duplicates-on-mysql-table) – Madara's Ghost Jul 29 '12 at 19:45
  • i would like to specify a point.. my question is not "how to remove duplicates from my table ". in my case same word is having 2 different lengths .. why ?? – srinath Jul 29 '12 at 20:13
  • Please update your question to include the PHP/MySQL code you used to determine the length of the words in the table. –  Jul 29 '12 at 22:17

1 Answers1

0

try and see if the word you want to insert already exists in the database. If so go to the next one, else insert it in the database. this is one way you can avoid duplicates, it doesnt answer the original question

Shpat
  • 502
  • 2
  • 9
  • 21
  • i tried select id,word,char_length(word) from list . i can see some words of same spelling with different length. what could be the reason? – srinath Jul 29 '12 at 20:15
  • @srinath try using char_length(trim(word)), maybe u have spaces!! – Shpat Jul 30 '12 at 14:09