Mysql delete duplicate rows in teble

Hi all,

  I have used the below code to delete duplicate entries. But when i execute this from server , 

i got the blank page with msg : Duplicate entry ‘Smith-799-track’ for key 2

$sql3="ALTER IGNORE TABLE shopping_cart ADD UNIQUE KEY(user,trackid,type)";
$result3=mysql_query($sql3) or die(mysql_error());

Here is a good article on how to remove duplicates in a MySQL database - just remember backup your table before doing this!

http://www.justin-cook.com/wp/2006/12/12/remove-duplicate-entries-rows-a-mysql-database-table/

Thanks for reply…
If its an small table, It will help. But I am developing shopping website. Huge users may come at a time. So, this process might be delay the users / create errors.

Please suggest some other query…

what is the primary key of this table?

My table stucture here…

– Table structure for table shopping_cart

CREATE TABLE shopping_cart (
s_no int(11) NOT NULL auto_increment,
sessionid varchar(100) default NULL,
user varchar(100) default NULL,
title varchar(100) default NULL,
artist varchar(100) default NULL,
trackid int(11) default NULL,
price varchar(50) default NULL,
track int(11) NOT NULL,
type varchar(100) NOT NULL,
date varchar(25) default NULL,
PRIMARY KEY (s_no),
UNIQUE KEY user (user,trackid,type)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=278 ;

it appears that your table actually does include the UNIQUE key you were trying to add in post #1

does the following query return any rows –

SELECT user
     , trackid
     , type
  FROM shopping_cart
GROUP
    BY user
     , trackid
     , type
HAVING COUNT(*) > 1