I made the column testname unique . But I did quite understand how to change
to query syntax.
Stephen told me to add where clause "Where IDENTIFIER NOT IN ( SELECT
IDENTIFIER FROM TABLE)"
I dont get what he means .. I am new to perl .
the table
show columns from phistory;
+-----------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------+-------------+------+-----+---------+----------------+
| num | int(4) | | PRI | NULL | auto_increment |
| testname | varchar(60) | YES | MUL | NULL | |
| numpeople | int(6) | YES | | NULL | |
| numtimes | int(6) | YES | | NULL | |
| average | float | YES | | NULL | |
+-----------+-------------+------+-----+---------+----------------+
5 rows in set (0.00 sec)
mysql>
CODE
my $sth1 = $dbh -> prepare("select distinct testname from testhistory");
$sth1 -> execute or die " unable to execute query ";
#$sth1 -> finish;
my $array_ref1 = $sth1->fetchall_arrayref();
foreach $row(@$array_ref1) {
my($tname) = @$row;
my $sth2 = $dbh -> prepare("insert into
phistory(testname)values('$tname')");
$sth2 -> execute or die " unable to execute query ";
#$sth1 -> finish;
}
thanks
Jim