in reply to Filtering MySQL results

Add WHERE group = 'admin' See many helpful online SQL tutorials for more information. You don't need the extra ' in your stmt.
$sth = $dbh->prepare("SELECT username,password,group FROM users WHERE group = 'admin'"); $sth->execute(); while( my ($user,$pass,$group) = $sth->fetchrow_array ) { print "$user,$pass,$group\n"; }
UpdateAh hah, you are using 'group' which is a reserved word for most RDBMs. Are you really sure that is what your table structure looks like?

Replies are listed 'Best First'.
Re(2): MySQL
by FoxtrotUniform (Prior) on Jul 18, 2002 at 21:45 UTC

    This is an excellent candidate for abstraction:

    sub get_group { my ($dbh, $group) = @_; my $sth = $dbh->prepare( "SELECT username, password, group FROM users WHERE group = ?"); $sth->execute($group) or warn "Can't select on group: $DBI::errstr\n"; my @users = (); while( my $user = $sth->fetchrow_hashref()) { push @users, $user; } return @users; }

    --
    The hell with paco, vote for Erudil!
    :wq