ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

How to delete duplicate entries from mysql table ?

user-image
تم إضافة السؤال من قبل Julfkar Moh Umar , Sr. Software Engineer , Aakash Edutech Private Limited
تاريخ النشر: 2016/01/11
Mohammad Ahmad Siddiqui
من قبل Mohammad Ahmad Siddiqui , Sr.Software Engineer , GSPANN Technologies Inc

Hi,

Add primary key in your table then you can easily remove duplicate entry.

Example:-

DELETE FROM master_table  WHERE id IN (SELECT * FROM (SELECT id FROM master_table GROUP BY master_id, master_quiz, master_question, master_ans HAVING (COUNT(*) >1) ) AS A);

 

Hope this help.

 

 

Julfkar  Moh Umar
من قبل Julfkar Moh Umar , Sr. Software Engineer , Aakash Edutech Private Limited

we insert auto increment on id column then run following command:

 

delete * from table_name where id > min(id) group by(column1,column2...collumnN) excluding column id

hamad alngadi
من قبل hamad alngadi

For example, with the following data:

SELECT*FROM names; +----+--------+| id | name |+----+--------+|1| google ||2| yahoo ||3| msn ||4| google ||5| google ||6| yahoo |+----+--------+

I would use SELECT DISTINCT name FROM names; if it were a SELECT query. How would I do this with DELETE to only remove duplicates and keep just one record of each?

المزيد من الأسئلة المماثلة