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 does mysqli_query return?
Which character is used to match exactly one character?
Can I use node js with php?
What is curl php?
Tell me what are the __construct() and __destruct() methods in a php class?
Tell me what is the importance of "action" attribute in a html form?
Which is better #define or enum?
What is smarty?
Explain what is meant by pear in php?
What is the php function that removes the first element of the array and returns it?
How do you display the output directly to the browser?
How to run a php script?
What is php variable?
Can php run on windows server?
Why do we use javascript in php?