I am reading a file which contains a record in each line. I am extracting the contents of the file and inserting it as column values into a table. The problem I face is, suppose if i insert a record into a table after reading from the file, I want to remove the duplicate fields. For example:
NAME age time
Tom 21 10:30
Tom 21 12:21
After insertion into the table I want it to be:
NAME AGE TIME
tom 21 10:30
12:21
It should eliminate the duplicates. If I add a unique condition while creating the table I face a problem that the distinct time field is not being inserted and results in an error in MySQL.
So how can I do this? I want some suggestions.
for my $test11 (sort keys %seen) {
my $test1 = $seen{$test11}{'name'};
my $test2 = $seen{$test11}{'pid'};
my $test3 = $seen{$test11}{'type'};
my $test4 = $seen{$test11}{'time1'};
print "$test11\t$test1$test2$test3$test4\n";
}
#sub query_execute()
{
$db_handle = &getdb_handle;
$sth = $dbh->prepare("INSERT INTO tahle_new values('$sno','$id','$test1','$test4','$test2','$test3')");
$test1
and $test2
contain duplicates but not $test3
.