Mysql UPDATE

Discussion in 'MySQL' started by rajivv, Jul 22, 2010.

  1. #1
    Hi,

    Need help filtering duplicates from a category

    fname- catid ( id of category)
    fname- company_name ( name of company)

    For catid () find all duplicate company_name

    Some categories eg. have the same company name 5 times

    What will be the sql command in phpmyadmin

    Regards
     
    rajivv, Jul 22, 2010 IP
  2. rajivv

    rajivv Peon

    Messages:
    335
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hi this is not a solution but I need a solution
    I dont have a queury
    Need to
    UPDATE table_product and remove duplicate company_name ( name of company)
    from cat_id (category)
     
    rajivv, Jul 22, 2010 IP
  3. koko5

    koko5 Active Member

    Messages:
    394
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    70
    #3
    Hi,

    So you need DELETE duplicates I guess...
    Can you please provide your create table script
    Regards :)
     
    koko5, Jul 22, 2010 IP
  4. Deacalion

    Deacalion Peon

    Messages:
    438
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #4
    What was the point in this post? ugh... fool.

    Try this method:

    1. Create a new table with the same fields as the original
    2. Extract all DISTINCT values from original table
    3. Insert them into the new table
    4. Drop original table
    5. Rename new table to original tables name

    or just add a unique index :)
    
    ALTER IGNORE TABLE your_table ADD UNIQUE INDEX(unique_field); 
    
    Code (markup):
     
    Deacalion, Jul 22, 2010 IP
  5. rajivv

    rajivv Peon

    Messages:
    335
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Hi,

    That also an option but we have close to 1 mil names in vendor names so duplicates are in these and across 8 categories
     
    rajivv, Aug 4, 2010 IP