Helpfulbox Now Offers Free POS Software for restaurants, kiosk, and any other retails business completely free used windows cashier system or as full blown POS. You will able to print to kitchen, display orders on the kitchen screen, manage inventory, employee, report, customer loyalty offers, employee management, delivery address track and much more, al for free.

mysql how to delete duplicate rows

By: Guest
Date: Mon-May-11-2009-
Response
2
You should always have a field that is a unique id for the record (i.e. autoincrement). It

makes it easier for differentiating and

deleting duplicates if needed. This query only works if you have a unique id field and it

will only delete one duplicate record at a

time. So if you have 4 records that are duplicates, you'll need to run it 3 times.

DELETE tablename

FROM tablename,

(SELECT MAX(uid) AS dupid,COUNT(uid) AS dupcnt

FROM tablename

GROUP BY id,url HAVING dupcnt>1)

AS dups

WHERE tablename.uid=dups.dupid;

Here is an example:

uid id url

1 20 google.com

2 25 yahoo.com

3 20 google.com

4 25 yahoo.com

5 20 google.com

The above query would delete uid 4 and 5 on the first run and ui 3 on the second run.

[d] By: Guest
Date: Mon-May-11-2009
Response
2
this one works 100% with keyid unique id

This is the proper format, allowing for easy debugging of errors…

DELETE

FROM table1

USING table1, table1 AS vtable

WHERE vtable.id > table1.id

AND table1.field_name = vtable.field_name

If you’re nervous about deleteing everything, you can make sure it’s working first:

SELECT *

FROM table1, table1 AS vtable

WHERE vtable.id > table1.id

AND vtable.field_name = table1.field_name

I just did this and it worked like a charm on hundreds of thousands of database entries.

[d] By: Guest
Date: Sun-May-17-2009
Response
What is 1 + 100



Helpfulbox Now Offers Free POS Software

for restaurants, kiosk, and any other retails business completely free. It can be used as windows cashier system or as full blown POS. You will able to print to kitchen, display orders on the kitchen screen, manage inventory, employee, report, customer loyalty offers, employee management, delivery address track and much more, all for free.

Just Updated::