Answer Posted / prakash.matte
If we have table 'temp' with columns: id(primary key),
field1, field2, field3, to remove the duplicate (field1,
field2, field3) data we can use either of the below queries
1. delete t1.* from temp t1, temp t2
where t1.id>t2.id and t1.field1=t2.field1 and
t1.field2=t2.field2 and t1.field3=t2.field3;
2. alter ignore table temp ADD UNIQUE INDEX
duprows(field1,field2,field3);
> here we can remove the duprows index by using the
following query:
alter table temp drop index duprows;
we can apply index on the columns as we don't require the
duplicate data, so we don't need to execute the query to
delete the index
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
What is session expiry?
Differentiate echo vs. Print statement.
What is the difference between laravel and php?
What are php filters?
can we swap two different string using php for example:-- before swapping:-- 1 string :-hello friend, 2 string :-my dear, after swapping that strings will be: 1.hello dear, 2.my friend.
How to redirect https to http url and vice versa in .htaccess?
How do I check environment variables?
Do csrf tokens expire?
Tell me how can we define a variable accessible in functions of a php script?
How easy is php?
Explain the difference between mysql_connect and mysql_pconnect?
What is php used for?
Can I learn php without knowing c?
Does php support overloading?
Tell me how comparison of objects is done in php5?