List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:May 10 2002 10:04pm
Subject:Re: quick sql question
View as plain text  
At 18:00 -0400 5/10/02, Augey Mikus wrote:
>is there a way for me to do it in a mysql delete statement?  just 
>out of curiosity, for instance, if i wanted to add duplicates later 
>for whatever reason.

Okay, let's suppose you have 3947 instances of "abc".
You can use LIMIT for this:

DELETE FROM tbl_name WHERE col_name = "abc" LIMIT 3946;


>
>Paul DuBois wrote:
>
>>At 17:54 -0400 5/10/02, Augey Mikus wrote:
>>
>>>what i meant is deleting duplicate occurences of records of a 
>>>certain field. ...sorry...
>>
>>
>>Ah.
>>
>>One thing you can do is add a unique index on that field with
>>ALTER IGNORE TABLE tbl_name ADD UNIQUE (col_name)
>>or
>>ALTER IGNORE TABLE tbl_name ADD PRIMARY KEY (col_name)
>>
>>and MySQL will clobber duplicate records as it builds the index.
>>
>>>
>>>
>>>Paul DuBois wrote:
>>>
>>>>At 17:16 -0400 5/10/02, Augey Mikus wrote:
>>>>
>>>>>what is the simplest way to delete duplicate occurences of a 
>>>>>specific field in mysql?
>>>>>
>>>>>thanks,
>>>>>
>>>>>augey
>>>>
>>>>
>>>>
>>>>Your question is a bit ambiguous.  You could do this by using ALTER
>>>>TABLE to remove the column itself from the table, for example, but
>>>>I'm guessing maybe that's not what you mean.

Thread
quick sql questionAugey Mikus10 May
  • Re: quick sql questionPaul DuBois10 May
  • Re: quick sql questionAugey Mikus10 May
    • Re: quick sql questionPaul DuBois10 May
  • Re: quick sql questionAugey Mikus10 May
    • Re: quick sql questionPaul DuBois10 May
  • Re: quick sql questionAugey Mikus11 May
  • Re: quick sql questionAugey Mikus11 May
    • Re: quick sql questionPaul DuBois11 May
      • Repair with key cachesup-mysql11 May
        • Re: Repair with key cacheBenjamin Pflugmann11 May
          • Re: Repair with key cachesup-mysql11 May
            • Re: Repair with key cachePaul DuBois12 May
              • Re: Repair with key cachesup-mysql12 May
              • Re: Repair with key cachesup-mysql12 May
                • Re: Repair with key cachePaul DuBois12 May
                  • Re: Repair with key cachesup-mysql12 May
                    • Re: Repair with key cacheJeremy Zawodny12 May
                      • RE: Repair with key cacheRamon Arias13 May
                        • Re: Repair with key cacheJeremy Zawodny13 May
  • Re: quick sql questionAugey Mikus11 May