[Dbix-class] Comparing two columns in a table

Jess Robinson castaway at desert-island.me.uk
Thu Mar 29 10:46:55 GMT 2007



On Thu, 29 Mar 2007, Matija Grabnar wrote:

> Say that I have a table which contains, among other stuff, two columns
> (call them a and b):
>
> I want to select only those rows where the two columns are unequal.
>
> select * from sometable where sometable.a != sometable.b;
>
> I've looked through Dbix::Class::Resultset and Cookbook, as well as 
> SQL::Abstract man page, and couldn't find anything that showed
> how to compare two columns in the same table, only how to use a function on a 
> column.
>
> Any ideas?

You'll need to use literal SQL, see SQL::Abstract docs for details.. 
Something like :

search({ cola => \'!= colb'})

Jess




More information about the Dbix-class mailing list