Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

using 'IN' clause in Class::DBI

by Anonymous Monk
on Dec 05, 2007 at 07:05 UTC ( #655042=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,
Please guide me to use 'IN' clause while using Class::DBI. I want to add IN condition in my existing query that is something like
$schema->resultset('Artist')->search( year => 1990 );

Replies are listed 'Best First'.
Re: using 'IN' clause in Class::DBI
by fenLisesi (Priest) on Dec 05, 2007 at 10:13 UTC
Re: using 'IN' clause in Class::DBI
by oha (Friar) on Dec 05, 2007 at 09:48 UTC
    given a statement like
    select * from mytable where id=1
    if you want to extend your search to more then one id, but a list obtained from another query, you can
    select * from mytable where id in (select id from table2)
    As you can see, it's related to your db and not all dbms support it.

    If i understood well, you want to "narrow" your search to a limited subset of artists, having no more data i'll write an example:

    select * from album where artist in (search artistId in artists where +year = 1990)
    Note that you can convert the IN clause with a INNER JOIN:
    select album.* from album a, artists b where a.artist = b.artistId and + b.year = 1990


Re: using 'IN' clause in Class::DBI
by perrin (Chancellor) on Dec 05, 2007 at 12:33 UTC
    Is year a column in your artist table, or is it in a different table?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://655042]
Approved by GrandFather
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2020-08-07 09:26 GMT
Find Nodes?
    Voting Booth?
    Which rocket would you take to Mars?

    Results (43 votes). Check out past polls.