Mysql
 sql >> Database >  >> RDS >> Mysql

Come posso generare la query SQL utilizzando SQL::Abstract?

Vedi not_bool opzione operatore unario:

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,
);

Ecco come $query guarda:

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