|
hi all...
i need to write a perl program which does the following:
it connects to the database and retrieves the rows from a table, which i am able to do.
For example, the table looks like this :
Name PID CID LID
a1 0 0 10
a1 0 0 20
a1 0 1 30
a2 0 2 40
a2 1 1 50
a3 0 1 10
so, here i need to check for duplicates and the rule is as folows:
eliminate duplicate rows which has the same CID, same PID and same name.
SO in the above example, i need to eliminate either row 1 or row 2. LID is NOT an issue here, i mean it does not matter if they are same or different.
I am storing all columns in separate arrays and then trying to sort based on columns. I just have an idea but I would like to have the perfect working code.
I will be grateful if some1 could provide me with one.
Thankyou.
Regards,
Abhilash
|
|
|
Hmmm not sure how you would do that efficiently =P
Perhaps look at "DistinctRow" sql statement.
fetch all the distinct combinations for those 3 columns and run through them. find out how many occurences there are for each distinct result. If there is more than 1 match, delete all but one.
|
|
|
just try to set LID and name as primary key before inserting values in database so it ll not allow duplication.
otherwise selct DISTINCT name,lid,cid from Tablename in sql query.
|
|
|
thank u for the reply.
I am not the DB admin and so i am not able to do so.
Anyways i fixed it.
You ppl are pretty late in replying.
Thank you .
Abhi
|
|
|
|
|
|
|
// |