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
Tell me how is it possible to return a value from a function?
How does one prevent the following warning ‘warning: cannot modify header information – headers already sent' and why does it occur in the first place?
What is the empty function?
How to declare an array in php?
How to remove duplicate values from array using php?
What type of language is php?
Is ruby on rails php?
What is php form validation?
What is http php?
How does php serialize work?
Explain how you can update memcached when you make changes to php?
How to open a file for reading?
Why framework is used in php?
What are the encryption techniques in php?
What software is required for php?