Question : How to avoid duplicate record in Mysql

I have two questions:

1- My table has duplicate records eg. same symbol,date,time but value is different.  How can I
    delete these duplicate records?

2- How can I modify my table so that whenever I insert a record (index selected based on
    symbol,date,time), the MySQL will reject those have the same index (combination of
   symbol,date,and time)?

Thx,
XT

Answer : How to avoid duplicate record in Mysql

You need an unique index. You can do this in one operation:

alter ignore table TableName add unique index IndexName (`symbol`,`date`,`time`);

This will delete duplicates and create an unique index, preventing future inserts of duplicate rows.
Random Solutions  
 
programming4us programming4us