mysql - How to fix data after changing key -


I have a table with many integers in the form of primary keys, one of them is a counter I need to remove the counter from the key is.

Deleting the counter from the key will duplicate several rows (with different counter values, but all other key elements are the same).

I need this to be a query that will remove all duplicates and leave only the row with the highest counter value. Any help is appreciated.

How about:

  create a table Fu (a number , B number, C number, obstruction pk_foo primary key (A, B, C)); Put in Fu (a, b, c) values ​​(0, 0, 0); Put in Fu (a, b, c) values ​​(0, 0, 1); Put in fu (a, b, c) values ​​(0, 1, 0); Put in Fu (a, b, c) values ​​(0, 1, 1); Put in Fu (a, b, c) values ​​(1, 0, 0); Put in Fu (A, B, C) values ​​(1, 0, 1); Put in Fu (A, B, C) values ​​(1, 1, 0); Put in fu (a, b, c) values ​​(1, 1, 1); Removing from foo t1 where not in t1.c (Select from maximum (t2.c) from foo t2 group a, b); Choose * from Foo; PS: You must remove  before  by removing  C  from the primary key. 


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -