my $d = DBI->connect( 'stuff', 'user', 'pass' ) || die("couldn't connect to database"); my ($min,$max) = $d->selectrow_array( "SELECT min(id),max(id) from images where foo like 'bar%'" ) #### mysql> SELECT min(id),max(id) from images where foo like 'bar%'; +---------+---------+ | min(id) | max(id) | +---------+---------+ | 61893 | 62437 | +---------+---------+ 1 row in set (0.59 sec)