On Fri, Jan 18, 2013 at 10:19:25AM -0800, Rajeev Prasad wrote:
> Hello,
>  
> I am trying to build a query based on two column values as folows:
>  
> columnA = x  (one char, any char - not null)
> columnB = zz _or_ x,xx,yyy,mm  (comma seperated values or just one value)
>  
>  
> I am looking for rows where: (columnB contains either zz or mm...)
>  
> columnA = x AND ( columnB = zz OR columnB LIKE '%mm%' )
>  
>  
>  
> I am trying following which is not giving correct results.
>  
>  
> $val = 'mm';
>  
>  $my_rs = $schema->resultset('Mytable')->search({
>               columnA => 'x',
>               columnB => { like => 'zz' },
>               columnB => { like => '%'.$val.'%' }
>               });
>  

Nobody explained why your original attempt did not work. What you feed 
to search() is a plain hash, with keys columnA and columnB. Supplying 
two values for the same hash-key has a well defined behavior - it only 
takes the last one. Hence the extra "clarifications" as shown in earlier 
replies.

Cheers!

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk

Reply via email to