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
How can you make a connection with mysql server using php?
How variables are passed through arguments?
Explain object-oriented methodology in php?
What is singleton pattern in php?
What is htaccess? Why do we use this and where?
Is salary fixed or variable cost?
Tell me how to find the length of a string?
What is the role of the .htaccess file in php?
Can php run without server?
Explain me what are the 3 scope levels available in php and how would you define them?
What is the string concatenation operator in php?
How to read one character from a file?
How to enable cURL in PHP?
Is php faster than python?
What is array filter php?