[CDBI] Re: Search by "or".
"Edward J. Sabol" <sabol-2oVx0MVsMgiP/[email protected]>
| Newsgroups | gmane.comp.lang.perl.modules.class-dbi |
|---|---|
| Message-ID | <[email protected]> |
> For a given column Is it possible to search for more than one value? > for instance how would I search for an employee with the first name > of either "William" or "Bill"? > > # Search for "William". > @employees = Comp::Employee->search( first_name => 'William' ); > > is "retrieve_from_sql" the only way to do this? Well, you could combine the results fo two searches: @employees = Comp::Employee->search( first_name => 'William' ); push @employees, Comp::Employee->search( first_name => 'Bill' ); In my experience, that could actually be faster with some databases! Or you could use CDBI::AbstractSearch: http://search.cpan.org/~miyagawa/Class-DBI-AbstractSearch/lib/Class/DBI/AbstractSearch.pm Hope this helps, Ed