[Dbix-class] union

Marc Mims marc at questright.com
Fri Apr 27 16:18:18 GMT 2007


* Octavian Rasnita <orasnita at gmail.com> [070427 08:10]:
> I don't need just a union, but a union that looks like:
> 
> select a, b, c, 'var1' as v from table1
> where d='value'
> union select a, b, c, 'var2' as v from table2
> where d='value'
> order by a, b desc limit 0,20;

You can create a result source for your query:

package MySchema::Whatever;
use base qw/DBIx::Class/;

__PACKAGE__->table('DUMMY');
__PACKAGE__->add_columns(qw/a b c v/);
__PACKAGE__->result_source_instance->name(\<<'');
(select a, b, c, 'var1' as v from table1
where d='value'
union select a, b, c, 'var2' as v from table2
where d='value')


1;



More information about the Dbix-class mailing list