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 session cookies php?
> symbol is used to redirect the output of a command. State Whether True or False?
What is final class and final method?
What is the role of php.ini file?
How do you clear environment variables?
Why do you need php?
How to enable cURL in PHP?
What is Apache's configuration file typically called?
iam mca post graduate in 2010 not getting job in JAVA so iam looking for carear in php as market demand is high so it is best option to try for php or not
What are the benefits of using php?
How do I display php errors?
What is cookie in php with example?
What is alias in php?
What is the current php version?
Who developed php?