my %in; $in{cid} = "something"; my $dbh = DBI->connect( $whatever… ) ... my $sth = $dbh->prepare( "select field from table where id != ?" ); $sth->execute( $in{cid} ); # the hash element value is the placeholder value ...