Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Write a query to to delete duplicate rows?

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


Please Help Members By Posting Answers For Below Questions

Write down the code for saving an uploaded file in PHP.

1114


What is the phpstorm?

1033


How is it possible to propagate a session id?

1058


Tell me what is the actually used php version?

1083


What is new static in php?

1053


What is php full form?

1127


What is difference between base_url and site_url?

1065


Do you know what is the difference between the include() and require() functions?

1025


What is the use session in php?

1087


Explain what is the difference between mysql_fetch_array() and mysql_fetch_assoc()?

940


How would you determine the size of a file in php?

1086


How do you use end in python?

1117


The left association operator % is used in PHP for?

1094


What is php variable?

1053


how to open & closing opening period in fico

1720