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%'" )