2010-10-12 84 views

回答

1

FIND_IN_SET不是标准SQL,所以SQL :: Abstract不支持它。但是,您可以将任何literal SQL放入SQL :: Abstract查询中。我希望你的解决方案落在这条路上。

3

此代码生成WHERE条款:

my $sql = SQL::Abstract->new;  

my %where = (
    id => 111, 
    -nest => \"NOT FIND_IN_SET(type, '1,2,3,4')", 
    status => 'pending', 
); 

my ($stmt, @bind) = $sql->where(\%where, \@order); 
6

not_bool元运算符选项:

use SQL::Abstract; 

my $sql = SQL::Abstract->new; 

my $where = { 
    id => 111, 
    status => 'pending', 
    -not_bool => "FIND_IN_SET(type, '1,2,3,4')", 
}; 

my ($query, @bind) = $sql->select( 
    'table', 
    'count(*)', 
    $where, 
); 

这是怎么$query如下:

SELECT count(*) FROM table WHERE (((NOT FIND_IN_SET(type, '1,2,3,4')) 
AND id = ? AND status = ?))