Answer Posted / vipul dalwala
For emample we have table called DUPtable.
DESCRIBE DUPtable;
+--------+-----------------+
| Field | Type |
+--------+-----------------+
| id | Auto Increament |
| field1 | varchar(20) |
| field2 | varchar(20) |
| field3 | varchar(20) |
+--------+-----------------+
And we want to delete duplicate rows from DUPtable (Same
combination of field1, field2 and field3) .
Solution:
Step 1: Create a Temporary table;
CREATE TEMPORARY TABLE tmpDUPtable
SELECT id FROM DUPtable GROUP BY field1, field2, field3;
Step 2: Delete query to remove Rows not in 'tmpDUPtable'
table.
DELETE from DUPtable WHERE id NOT IN (SELECT id FROM
tmpDUPtable);
Step 3 DROP tmpDUPtable
DROP TABLE tmpDUPtable;
I hope this will help.
Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
What is preg_match?
Tell me what sized websites have you worked on in the past?
How to access a global variable inside a function?
CWD is a type of shell variable. State Whether True or False?
Do you know what does mvc stand for and what does each component do?
What is difference between static and constant?
What is different between software and app
How to store the uploaded file to the final location?
Is it possible to extend the execution time of a php script?
What are the characteristics of php variables?
What is the Default syntax used in PHP?
What is memcache?
Where are php configuration settings stored?
What are php string functions?
Which Scripting Engine PHP uses?