[Dbix-class] Subquerys

Jess Robinson castaway at desert-island.demon.co.uk
Sat Dec 30 02:40:23 GMT 2006



On Wed, 27 Dec 2006, Moritz Onken wrote:

> How do I write this query in dbix-class syntax?
>
> DELETE FROM chat
>   WHERE ( chat.ID
>     NOT IN (
>       SELECT chat.ID FROM chat
>         ORDER BY chat.time DESC LIMIT 0,20 ))
>
> thanks

Currently, by doing something like:

->search({ -and => [1, \'chat.ID NOT IN (SELECT ... )']})->delete;

Jess




More information about the Dbix-class mailing list