Thursday, 22 August 2013

Delete Duplicate Entry & Update Table By Copying Data From One Table to Other

Suppose you want to take regular updates from various servers and store them in your own database for any valid reason. Then you will face problem of duplicate entry in your database. To understand this suppose you want to store various RSS Feeds news for further analysis then you will automatically refresh your page in certain time interval but in such situation your database will capture various duplicate entry also. To avoid such thing happen with you you will have to manage it will proper algorithm. Okay look at this technique and i hope this will help you a lot.

1. Take Two Table named as "FirstTable" and "SecondTable". Second Table will be your main table which stores actual data without duplicate entry. First Table will store updates only.

2. With the help of some logic we first take our updates first to "FirstTable" and then we will check weather "SecondTable" has same rows or columns.

3. If it has same rows and columns then delete such entry from "FirstTable".

4. Now copy "FirstTable" unique entry into "SeconTable" with the help of Sql Commands. so look at these command you can store it in your Database.
(This Blog is further extension of our previous tutorial Display RSS Feeds in Your Website & If Needed How to Store Them in DataBase ).

With the help of Two Sql Commands you can achieve such things as. (In my tables I have three Rows Common in both tables "Title", "Description", "Link" )   
Hope this will help you if not look at the full coding in picture below