Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [MySQL]Jak usunąć ten same id's i zostawić tylko jeden?
Saki
post
Post #1





Grupa: Zarejestrowani
Postów: 240
Pomógł: 2
Dołączył: 5.12.2010
Skąd: Fulda

Ostrzeżenie: (0%)
-----


W kolumnie ID mam kilka tych samych numerów, jak usunąć je i zostawić tylko jeden id?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 2)
Pyton_000
post
Post #2





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

Ostrzeżenie: (0%)
-----


masz kilka takich samych rekordów? Chcesz zostawić obojętnie który?
Go to the top of the page
+Quote Post
Saki
post
Post #3





Grupa: Zarejestrowani
Postów: 240
Pomógł: 2
Dołączył: 5.12.2010
Skąd: Fulda

Ostrzeżenie: (0%)
-----


<l__q> How do delete in column all duplicate ID's and leave just one?
<threnody> !t l__q about dupes
<ubiquity_bot> l__q: find them with SELECT COUNT(*) as qty,dupefield[,otherfields] FROM table GROUP BY dupefield[,otherfields] HAVING qty > 1
<threnody> !t l__q about delete dupes
<ubiquity_bot> l__q: If you have a unique ID and the name may contain duplicates then DELETE t1 FROM table1 AS t1 JOIN table1 AS t2 ON t1.id>t2.id AND t1.name=t2.name; If you have other fields that need to be taken into consideration extend the join as needed. If it fails on a myisam table see http://bugs.mysql.com/bug.php?id=28837
<threnody> l__q: if you don't care which rows are deleted you can just do ALTER IGNORE TABLE foo ADD UNIQUE(`col`); <-- that will add a unique index on the column in question and drop duplicate rows
<threnody> l__q: backup first, of course
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 25.08.2025 - 01:12