Good day. How to get the result of an SQL query based on data from another.
my $COUNTER =0; while ($COUNTER<=900){ my $sql = "SELECT f1 FROM TND where ID='$COUNTER'"; my $sth = $db->prepare($sql); $sth->execute(); my $A=$sth->fetchrow_arrayref(); my $sql1 = "select ID,f1,sum(f2) from TND where f1='@$A'"; my $sth1 = $db->prepare($sql1); my $B; my @B; while(@B=$sth1->fetchrow_arrayref()){ print "@B"; }; $COUNTER++; } The script is completed without giving me anything.
select a.f1, sum(a.f2) from TND a, TND b where a.f1=b.f1 and b.id between 0 and 900 group by a.f1