On 2006-06-20 09:46:53 -0700, Aran Deltac wrote: > SELECT COUNT(*) > FROM lang.translations tf > LEFT JOIN lang.translations tt > ON (tf.customer_group_id=tt.customer_group_id AND > tf.message_code=tt.message_code) > WHERE tt.customer_group_id=0 > AND tf.language_code="en" > AND tt.language_code="fr" > AND (tt.translation=tt.message_code OR tt.translation=tf.translation);
In your table class: # Self-join __PACKAGE__->has_many( tt => 'YourSchema::Translations', { 'foreign.customer_group_id' => 'self.customer_group_id', 'foreign.message_code' => 'self.message_code', }, ); In your code: $schema->resultset('Translations')->count( { 'tt.customer_group_id' => 0, 'me.language_code' => 'en', 'tt.language_code' => 'fr', -or => [ 'tt.translation' => \'= tt.message_code', 'tt.translation' => \'= me.translation', ], }, { join => 'tt', }, ); Maybe? There might be a simpler way, but that's what I came up with against a schema here. -- Daniel Westermann-Clark _______________________________________________ List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class Wiki: http://dbix-class.shadowcatsystems.co.uk/ IRC: irc.perl.org#dbix-class SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/ Searchable Archive: http://www.mail-archive.com/dbix-class@lists.rawmode.org/