$dbh->prepare('SELECT name, email, from - to AS duration FROM table WHERE duration > ?'); $dbh->bind_columns(\my ($name, $email, $duration); $dbh->execute($min_duration); while ($sth->fetch) { say "$name <$email> has spent $duration days here"; }